Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

How to stop task and mouse cursor when having exception

$
0
0

m using the following code and the problem is that when I have exception in GetUserData() I get message to the UI and the mouse courser is not stopping ,when I put inside the catch the mouse Cursors.Null cause to dump. my questions is:

  1. How I can stop the task (tpl) when I got exception i.e. not proceed to the continueWith ?
  2. How can I omit the mouse cursor when I got exception ?
Mouse.OverrideCursor=Cursors.Wait;Task.Factory.StartNew(()=>{//-----get service Data ---------try{GetUsersData();}catch(Exception e){
            _isValid =false;ThrowErrorMessage(e.Message);Mouse.OverrideCursor=Cursors.Null;}}).ContinueWith((task)=>{Mouse.OverrideCursor=null;},System.Threading.CancellationToken.None,TaskContinuationOptions.None,TaskScheduler.FromCurrentSynchronizationContext());

    isServiceValid =true;

Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>