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

前端 未结 10 2242
有刺的猬
有刺的猬 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:41

    Add

    t1.Join();    // Wait until thread t1 finishes
    

    after you start it, but that won't accomplish much as it's essentialy the same result as running on the main thread!

    I can highly recommended reading Joe Albahari's Threading in C# free e-book, if you want to gain an understanding of threading in .NET.

提交回复
热议问题