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);
 }
Ejemplo n.º 2
0
        /// <summary>Submit a .Net task to the specified completion service</summary>
        /// <param name="executor">The compeletion service to submit the task to</param>
        /// <param name="task">The task to submit</param>
        /// <returns>A <c>Future</c> instance</returns>
        public static Future Submit(this JPPFCompletionService completionService, BaseDotnetTask task)
        {
            DotnetSerializer ser = new DotnetSerializer();

            byte[]            bytes = ser.Serialize(task);
            DotnetTaskWrapper dtw   = new DotnetTaskWrapper(bytes);

            //if (task.TimeoutSchedule != null) dtw.setTimeoutSchedule(task.TimeoutSchedule);
            dtw.setLoggingEnabled(false);
            return(completionService.submit(dtw, dtw));
        }
Ejemplo n.º 3
0
        /// <summary>Add a .Net task to the specified job. The .Net task is serialized and the resulting byte[] is
        /// held by the returned <c>DotnetTaskWrapper</c> instance on the Java side.
        /// <para>This is a method extension to the JPPFJob proxy class generated by jni4net.</para></summary>
        /// <param name="job">The job to add the task to</param>
        /// <param name="task">The task to add</param>
        /// <param name="loggingEnabled">Whether the Java wrapper for this task will print messages to the console during its execution</param>
        /// <returns>A <c>Task</c> instance</returns>
        public static Task add(this JPPFJob job, BaseDotnetTask task, bool loggingEnabled)
        {
            DotnetSerializer ser = new DotnetSerializer();

            byte[]            bytes = ser.Serialize(task);
            DotnetTaskWrapper dtw   = new DotnetTaskWrapper(bytes);

            if (task.TimeoutSchedule != null)
            {
                dtw.setTimeoutSchedule(task.TimeoutSchedule);
            }
            dtw.setLoggingEnabled(loggingEnabled);
            return(job.add(dtw));
        }
Ejemplo n.º 4
0
 /// <summary>Add a .Net task to the specified job. The .Net task is serialized and the resulting byte[] is
 /// held by the returned <c>DotnetTaskWrapper</c> instance.
 /// <para>This is a method extension to the JPPFJob proxy class generated by jni4net.</para></summary>
 /// <param name="job">The job to add the task to</param>
 /// <param name="task">The task to add</param>
 /// <returns>A <c>Task</c> instance</returns>
 public static Task add(this JPPFJob job, BaseDotnetTask task)
 {
     return(job.add(task, false));
 }