c# - How to Toast Notification when win app is closed in WP8? -


i want implement toast , tile notifications. notification must meet criteria, such needs able run when app closed. example, birthday reminder can run in background when app closed.

sample found:

shelltoast toast = new shelltoast(); toast.title = "toast title: "; toast.content = "test"; toast.show(); 

the above example works when app running. here code:

    private void startperiodicagent()     {         // variable tracking enabled status of background agents app.         agentsareenabled = true;          // obtain reference period task, if 1 exists         periodictask = scheduledactionservice.find(periodictaskname) periodictask;          // if task exists , background agents enabled         // application, must remove task , add again update          // schedule         if (periodictask != null)         {             removeagent(periodictaskname);         }          periodictask = new periodictask(periodictaskname);          periodictask.expirationtime = system.datetime.now.adddays(1);          // description required periodic agents. string user         // see in background services settings page on device.         periodictask.description = "this demonstrates periodic task.";          // place call add in try block in case user has disabled agents.          scheduledactionservice.add(periodictask);     }    private void runbackgroundworker()     {         //phonecalltask calltask = new phonecalltask();         //calltask.phonenumber = "03336329631";         //calltask.displayname = "arslan";         //calltask.show();           backgroundworker backroungworker = new backgroundworker();          backroungworker.dowork += ((s, args) =>         {             thread.sleep(10000);         });          backroungworker.runworkercompleted += ((s, args) =>         {             this.dispatcher.begininvoke(() =>             {                 var toast = new toastprompt                 {                     title = "simple usage",                     message = "message"                 };                 toast.show();                 }         );         });         backroungworker.runworkerasync();     } 

but don't notifications. can tell me how set notifications work when app isn't running?

backgroundworker different scheduled task schedule periodic running.

add windows phone scheduled task agent , in project write code logic invoke necessary calls producing toast.

protected override void oninvoke(scheduledtask task) {   ------------------------------------------------   code scheduled task running. }  

once code has been completed, can call notifycomplete() indicate once work of scheduled task over.

whereas backgroundworker runs code in separate thread , there no correlation scheduled task other fact that; can use background thread in scheduled task.

in order logic shared across main application , scheduled task:- create separate project , put reusable/shared code inside it. refer in main app , scheduled task sharing/accessing variables.

make use of isolatedstoragefile , mutex in separate project , share dll across both

*random reference schedule task example: http://wildermuth.com/2011/9/6/periodic_agents_on_windows_phone_7_1*


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -