0
votes
public void loadtemplist(DataTable dt)
    {
      this.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle,

          (Delegate) (() => this.loadtemplist1(dt))   //error


          );
    }

and

public void loadtemplist1(DataTable dt)
    {

-----
-----

}

the above code throws Cannot convert lambda expression to type 'System.Delegate' because it is not a delegate type

2

2 Answers

1
votes

You can't convert an anonymous method straight to a System.Delegate - you need to wrap it in an Action first.

Try this instead:

public void loadtemplist(DataTable dt)
{
  this.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle,

      new Action(() => { this.loadtemplist1(dt); } )
      );
}
0
votes

you should do

this.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, 
                            new Action(() => this.loadtemplist1(dt)) );

see demo: https://dotnetfiddle.net/nz9xxD