c# - I cant seem to use dependency injection in WinRT BackgroundTask -


i implementing ibackgroundtask in windows runtime component , i'd inject logger dependency application exits when calls background task. won't enter constructor. i'm using ninject di container , have no problems using anywhere else in app.

i'd this:

private readonly ilog _logger;  public backroundtask(ilog logger) {     _logger = logger; }      public async void run(ibackgroundtaskinstance taskinstance)     {         var deferral = taskinstance.getdeferral();          try         {             // here         }         catch (exception ex)         {             // log error injected logger...             logger.errorformat("{0}error in queuetimer {1}{0}",                 environment.newline, ex.tostring());         }          deferral.complete();     } 

i've had no success i've tried , log on oncomplete method in calling .cs file.

in limited experience creating windows store applications, must supply default constructor background tasks; other constructors won't called.

hopefully i'm wrong this, though; practical able pass background tasks' dependencies in, i'm not sure if makes sense since own code might not running when task starts. think way communicate between program , task using permanent storage.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -