私はあなたの助けを前もって感謝します。私はかなりプログラミングに新しいので、簡単に私に行く。今はUIスレッドの外で実行する必要がある時間がかかるループがあります。これはUpdate()がプログレスバーを更新するので、このループが完了するまでは起こりません。私はいくつかの短いスレッドチュートリアルを見てきました。大きなループが終了するまで更新はレンダリングされません。コードのセクションを別のスレッドに配置していますか?
private void Button_Convert_Click(object sender, RoutedEventArgs e)
{
MachineAngleCalculations.Instance.Arm1Length_Arbitrary = 12;
MachineAngleCalculations.Instance.Arm2Length_Arbitrary = 11;
int resolution = 100000; //points per shape
double xstep, ystep, x, y;
int totalpoints = resolution * ShapeList.Count;
int calculatedpoints = 0;
ProgStat.Update(calculatedpoints, totalpoints, "Calculated", "individual instructions.");
InstructionList.Clear();
foreach (MachineLine item in ShapeList)
{
xstep = (item.End.X - item.Start.X)/(resolution - 1);
ystep = (item.End.Y - item.Start.Y)/(resolution - 1);
for (int i = 0; i < resolution; i++)
{
x = item.Start.X + xstep * i;
y = item.Start.Y + ystep * i;
InstructionList.Add(MachineAngleCalculations.Instance.XYtoMachineInstrution(x, y, 1));
calculatedpoints += 1;
ProgStat.Update(calculatedpoints, totalpoints, "Calculated", "individual instructions.");
}
}
}
だから、別のスレッドでforeach
ループを実行する最も簡単な方法は何ですか? これを別の機能に入れないで行う方法はありますか?
http://stackoverflow.com/questions/670510/threading-in-net –