本文介绍了如何在C#中设置线程优先级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在c#.net 4的backgroundworker_dowork()事件中调用了三种方法.我想同步执行三种方法.也就是说,第二种方法将在第一种方法完全执行后执行,而第三种方法将在第二种方法完全执行后执行.因为只有在第一种方法完全执行后,第二种方法才能正确释放.但是在后台工作器中,这三种方法都是我不希望异步执行的.

如何解决?

在此先感谢.

there are three methods called in a backgroundworker_dowork() event in c# .net 4. I want to execute three methods synchronously. that is, 2nd method will execute after 1st method is fully executed and 3rd method will execute when 2nd method is fully executed. because 2nd method can exetue properly only when 1st method is fully executed. but in the background worker all three methods are executed asynchronously that i don''t want.

How to solve it?

Thanks in advance.

推荐答案

Private Sub StartWork()
    Method1()
    Method2()
    Method3()
End Sub


每个方法将按顺序执行,并且每个方法都将等待前一个方法执行完毕,然后再开始下一个方法.


Each method will get executed in order and each will wait for the previous method to finish execution before the next one starts.




这篇关于如何在C#中设置线程优先级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-30 04:47
查看更多