Is this you? As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.
Claim your profile
Articles by Return Propertyinfo. GetValue
如何在long-running task中调用async方法
long-running task 是指那些长时间运行的任务,比如在一个 while True 中执行耗时较长的同步处理。 下面的例子中,我们不断从队列中尝试取出数据,并对这些数据进行处理,这样的任务就适合交给一个 long-running task 来处理。 var queue = new BlockingCollection<string>(); Task.Factory.StartNew(() => { while (true) { // BlockingCollection<T>.Take() 方法会阻塞当前线程,直到队列中有数据可以取出。 var input = queue.Take(); Console.WriteLine($"You entered: {input}"); } }, TaskCreationOptions.LongRunning); while (true) { var input = Console.ReadLine(); queue.Add(input); } 在 .NET 中,我们可以使用 Task.Factory.StartNew 方法并传入...
Show More
loading
Actions
Is this you?
As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.Get in touch with Return Propertyinfo.
Contact Return Propertyinfo., search articles and posts on X, monitor coverage, and track replies from one place.
Learn more about Muck Rack