Exception handling in multithreaded C#

try
{
  Parallel.Invoke(
    () =>
    {
      Console.WriteLine("Starting Job 1..");
      Thread.Sleep(3*1000);
      Console.WriteLine("Starting Job 1.. SUCCESS");
    },
    () =>
    {
      Console.WriteLine("Starting Job 2..");
      throw new Exception("Job 2 Failed");
    }
  );
}
catch (AggregateException ex)
{
  Console.WriteLine(ex);
  foreach (var innerEx in ex.InnerExceptions)
  {
    Console.WriteLine(innerEx);
  }        
}

Comments

  1. Neither life nor playing presents any guarantees, and your precise day by day results may be be} far totally different than your theoretical loss, so plan accordingly. Freshen up your ground, interact players and drive growth with IGT Fruit Games. QuikTicket™ is an enhanced way to play Slots, the place have the 카지노 사이트 ability to|you possibly can} entry your cash without debit account day by day withdrawal limits.

    ReplyDelete
  2. The course of offers a completed part without stresses on the material. Sinker EDM has a greater variety|a higher diversity} of Bottle Warmers applications, corresponding to blind cavities/key-ways, thin partitions, or cross sections. With no restrictions on materials, our Online Machining Service has you lined does not matter what} you want us to machine. There are also no limitations on amount, we feel top quality, machined parts ought to be affordable when ordering 1 or 5,000. PartsBadger is ITAR Registered and can protect the interests and security of our customers and their projects. Manufacture parts with complicated cuts and angles utilizing a variety of|quite a lot of|a wide range of} precision cutting, drilling, and lathing instruments.

    ReplyDelete

Post a Comment

Popular posts from this blog

Parse XML to dynamic object in C#

Parse XML to object model in C# using XSD utility