Ejemplo n.º 1
0
 /// <summary>deserialize the specified <c>byte[]</c> into a <c>BaseDotnetTask</c>,
 /// invoke its <c>Execute()</c> method, then serialize its new state</summary>
 /// <param name="bytes"></param>
 /// <returns>a <c>bytes[]</c> holding the state the task after execution</returns>
 public byte[] Execute(byte[] bytes)
 {
     if (cancelled)
     {
         return(bytes);
     }
     currentThread = Thread.CurrentThread;
     try {
         //System.Console.WriteLine("deserialized object: " + obj);
         task = (BaseDotnetTask)Deserialize(bytes);
         if (cancelled)
         {
             return(bytes);
         }
         try {
             task.Execute();
         } catch (ThreadInterruptedException e) {
             Console.WriteLine("" + e);
         } catch (Exception e) {
             task.Exception = e;
         }
         if (cancelled)
         {
             return(bytes);
         }
         return(Serialize(task));
     } finally {
         currentThread = null;
         task          = null;
     }
     return(bytes);
 }