c# - Update lock screen using a ScheduledTaskAgent -


I want to be able to update my lock screen image using a scheduled task agent. I saw a good article what my problem is in this video that it has been shown how to change your background with a picture from your individual storage. Using:

  URI Image URI = New Uri ("MS-AppData: ///local/shared/shellcontent/background2.png", Uricund.relative orsolute);   

is not my case (I have to download it from webservice) I created a small project with a piece of code in which an image should be downloaded, it stored on my separate storage And then have to use it to upload my lock screen (I think this is the best way to do what I have to do.).

I used to do this:

  Safe override zero onewolk (scheduled task assignment) {deployment.Current.Dispatcher.BeginInvoke ((=) => {SavePictureInIsolatedStorage (new URI ( "Http://www.petfinder.com/wp-content/uploads/2012/11/101418789-cat-panleukopenia-fact-sheet-632x475.jpg")); // Lokhelpr (); NotifyComplete ();}); }   

and:

  Private async zero SavePictureInIsolatedStorage (URI background image Yuri) {bitmap image bmp = new bitmap image (); Wait for the job. (() = & Gt; {heroic semaphore = new manual reset Avant (false); deployment. Current. Dispacr Kbijininvok ((=) = & gt; {bmp = new Bitmap image (background image), semaphore Kset () ;}); Semaphore.Watton ();}); Bmp.CreateOptions = BitmapCreateOptions.None; Writeable bitmap wbmp = new writable bitmap (BMP); (Separate storage file by using myIsolatedStorage = isolated storage file.Netuserstoreforor applications ()) {var file = "shared / shellcontent / lockscreen.png"; // When the file exists, delete it (myIsolatedStorage.FileExists (file)) {myIsolatedStorage.DeleteFile (file); Use} (var isoFileStream = Use New IsolatedStorageFileStream (file, FileMode.Create, myIsolatedStorage)) {// ToolStackPNGWriterExtensions ToolStackPNGWriterLib.PNGWriter.WritePNG (wbmp, isoFileStream); }}}   

My problem is that my bitmap image is not downloaded. I have also tried with a web client, I am facing the same result.

You are not waiting for your call, so notify () Will get an opportunity to run before doing anything. You can fix this by declaring your lambda function as async .

  protected override void OnInvoke (Scheduled Tasks function) {deployment.Current.Dispatcher.BeginInvoke (async () = & gt; {wait SavePictureInIsolatedStorage (new URI ( "http: //www.petfinder .com / Wp-content / uploads / 2012/11/101418789-cat-panleukopenia-fact-sheet-632x475.jpg ")); NotifyComplete ();}); }   

However considering that your method does not take much time to run, otherwise your scheduled task will not be scheduled again (after 2 such failures).

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -