Passing a method to a backgroundworker dowork

前端 未结 3 1961
感动是毒
感动是毒 2021-01-14 11:50

In the code below, is there a way to instead of always subscribing the updateWorker_DoWork method, pass it a method like this

public void GetUpdates(SomeObje         


        
3条回答
  •  旧时难觅i
    2021-01-14 12:11

    If I didn't misunderstand you, you need lambda expressions to construct anonymous method.

    updateWorker.DoWork += (sender,e)=>
      {
          //bla
      }
    

    Now you needn't always to write a method and pass it to new DoWorkEventHandler(myMethod)

提交回复
热议问题