How can I wait for a thread to finish with .NET?

前端 未结 10 2308
有刺的猬
有刺的猬 2020-11-22 10:27

I\'ve never really used threading before in C# where I need to have two threads, as well as the main UI thread. Basically, I have the following.

public void S         


        
10条回答
  •  佛祖请我去吃肉
    2020-11-22 10:42

    Try this:

    List myThreads = new List();
    
    foreach (Thread curThread in myThreads)
    {
        curThread.Start();
    }
    
    foreach (Thread curThread in myThreads)
    {
        curThread.Join();
    }
    

提交回复
热议问题