Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dealing with Tasks and exceptions
Message
 
 
To
All
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Dealing with Tasks and exceptions
Environment versions
Environment:
C# 5.0
OS:
Windows 10
Database:
MS SQL Server
Miscellaneous
Thread ID:
01643823
Message ID:
01643823
Views:
24
UPDATE. Never mind, solved it.

Hi everybody,

I'm trying the following pseudo-code
try

{

    some code here

     Task<T> task = SomeTask();

     T result = null;
     while (someCondition)
     try
     {
          result = task.Result;
      }

      catch (TaskCanceledException te)
     {
          code here
     } 
     catch (WebException we)
     {
          code here
      }
} // close while loop


        if (result!=null)
         {
           some code here
         }
} close try

catch (Exception e)
{
   main catch here
}
When I'm debugging my test, I am always hitting the outer exception and not the inner exception. The line result = task.Result generates the error. The inner exceptions says that task was cancelled.

What should I do to fix my algorithm?

Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Reply
Map
View

Click here to load this message in the networking platform