Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Dealing with Tasks and exceptions
Message
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Dealing with Tasks and exceptions
Versions des environnements
Environment:
C# 5.0
OS:
Windows 10
Database:
MS SQL Server
Divers
Thread ID:
01643823
Message ID:
01643823
Vues:
25
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
Répondre
Fil
Voir

Click here to load this message in the networking platform