How do I make an eventhandler run asynchronously?

前端 未结 7 670
迷失自我
迷失自我 2020-12-04 11:15

I am writing a Visual C# program that executes a continuous loop of operations on a secondary thread. Occasionally when that thread finishes a task I want it to trigger an e

7条回答
  •  南方客
    南方客 (楼主)
    2020-12-04 12:08

    With the Task Parallel Library it is now possible to do the following:

    Task.Factory.FromAsync( ( asyncCallback, @object ) => this.OperationFinished.BeginInvoke( this, EventArgs.Empty, asyncCallback, @object ), this.OperationFinished.EndInvoke, null );
    

提交回复
热议问题