Beispiel #1
0
        /// <summary>Convert a JPPF <c>Task</c> into a <c>BaseDotnetTask</c>.</summary>
        /// <param name="job">A JPPF job to which the task belongs</param>
        /// <param name="task">The task to convert</param>
        /// <returns>A <c>BaseDotnetTask</c> instance, or <c>null</c> if the input task is not an instance of <c>DotnetTaskWrapper</c></returns>
        public static BaseDotnetTask AsBaseDotnetTask(this Task task)
        {
            DotnetTaskWrapper dtw = task as DotnetTaskWrapper;

            if (dtw != null)
            {
                DotnetSerializer ser = new DotnetSerializer();
                return((BaseDotnetTask)ser.Deserialize(dtw.getBytes()));
            }
            return(null);
        }
Beispiel #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));
        }
Beispiel #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));
        }