c# - Dispatcher.Invoke with anonymous delegate works in Silverlight but not WPF -


I have a custom service class in Silverlight 4 that has an asynchronous full event. Within the full event, I returned Take data and open any populate method like this:

  Private zero service_completed (Object Sender, CompletedEventArgs args) {Dispatcher.BeginInvoke ((= =) populateInbox (args.Jobs )); } Private Zero populateInbox (List & nbsp; JobViewModel> Jobs) {inbox.DataContext = jobs; }  

In SL4, BignineWolk works, but when I put it in WPF, I get the following error:

< P> can not be changed This is not a representative type

because I tried to change it to an in-line, anonymous, parametric representative:

 < Code> Dispatcher.BusinessWeb (Representative (List; JobVoiceModel> Jobs) {inbox.DataContext = jobs;});  

However, it generates similar compile-time errors.

Any idea how to work in WPF? Refactoring is not an option for me to use the background worker .

You just need to specify a clear representative type just a action Use

  Dispatcher.BeijinWolk (new action (=) (Populate inbox (ajajjob));  

Jobs can avoid closing the value:

  Dispatcher.BeginInvoke (new action (jobs) => PopulateInbox (jobs), jobs;  

This is because the single-parameter version of Dispatcher.BeginInvoke has a different signature in Silverlight compared to WPF in Silverlight, it is a verb Which takes the C # compiler to its lambda Allows to be vested in the form of verb {/ code>}. In WPF, it is a representative (its Control.BeginInvoke like analog in Winforms) , Therefore the C # compiler must be a representative type clearly specified.


Comments