在C#中进行线程化.可以中断的任务

ALO*_*LOR 5 c# concurrency

在我的程序中,我有一些非常长的任务,应该可以从GUI(WPF)中断.有关线程架构的任何建议吗?

此任务看起来像N线程与此类代码:

public void DoLongOperation()
{
    for(int i=beginPoint; i<endPoint; i++)
    {
       doSomethingStupid(dataArray[i]);
    }
}
Run Code Online (Sandbox Code Playgroud)