c# - How to use Observable.FromEvent with static events? -


Text after "div class =" itemprop = "text">

I use reactive extensions to write code to handle an asynchronous call where both the beginning method and the whole event are stable I'm trying to I can not use

  on languageSetsLoaded = direct .fromEvent & LT; LoadLanguageSetsCompletedEventArgs & gt; (LanguageManager, "LanguageSetsLoaded")  

As an example, LanguageManager is a static class, so I tried to

languageSetsLoaded on = Direct .FromEvent & LT; LoadLanguageSetsCompletedEventArgs & gt; (H = & gt; LanguageManager.LanguageSetsLoaded + = h, h => LanguageManager.LanguageSetsLoaded - = h)

But this syntax gives error "lambda expression 'object' type Can not be changed because it is not a representative type ". This event has been announced

  Public Representative Zero Load Language Attribute Handler (Load languagesAppeted EventErguesE); Public Stable Event LoadLanguageSetsCompletedHandler LanguageSets Loaded = Rep? {};  

So I think that this is the type of representative and perhaps the fact that it is stable, creating a misleading error statement.

Is there any way to do this or is I just going to follow the non-reactive code like this? Private zero ChangeLanguage = OnLanguageSetsLoaded? LanguageManager.LoadLanguageSets (LanguageCode, BaseApp.InTranslationMode); } Private Wide Online Language Sets Loaded (Load Language Sets Applied Avenger AGE E) {LanguageManager.LanguageSetsLoaded - = On Language Sets Loaded; OnPropertyChanged ("DummyLanguageResource"); }

I think the problem is your representative has an event, trying to change it Do:

  Public Static Events EventHandler & lt; LoadLanguageSetsCompletedEventArgs & gt; Languagesetloaded = delegate {}; Look at the signature of  

, then Observable.FromEvent is that you are trying to use, it looks like this:

< Pre> public static IObservable & lt; IEvent & lt; TEventArgs & gt; & Gt; FromEvent & LT; TEventArgs & gt; (Action & lt; eventhandler & lt; teventArgs & gt; addHandler; & lt; eventhandler & lt; teventArgs & gt; removeHandler); where the TEventArgs: EventArgs

Alternatively you can use the three logic, the first one is going to be a conversion handler - but I think that you are just changing the event signature, then at all possible

would be better.

Comments