Пример #1
0
 public string ExecuteOutput(string id, Hashtable vars)
 {
     string output = "";
     TextWriter consoleOut = Console.Out;
     try
     {
         if(this.assembly != null)
         {
             Thread exeThread = new Thread(new ThreadStart(this.runOutput));
             Job job = new Job();
             job.Name = this.OUTPUT_PREFIX + id;
             job.Args.Add(new StringTable(vars));
             this.threadJobs[exeThread] = job;
             exeThread.IsBackground = true;
             exeThread.Start();
             exeThread.Join(5000);//join when done or in 5 sec.
             //copy any vars changes back into the main vars object
             vars.Clear();//we need to do this in case any were deleted
             foreach(string key in ((StringTable)job.Args[0]).Keys)
             {
                 if(vars[key] == null || vars[key] is string)
                     vars[key] = ((StringTable)job.Args[0])[key];
             }
             output = (string)this.threadJobs[exeThread].Result;
             this.threadJobs[exeThread] = null;//clean up the thread job
         }
     }
     catch{}
     finally
     {
         Console.SetOut(consoleOut);
     }
     return output;
 }
Пример #2
0
        public string ExecuteStandardJob(string methodName, object[] args)
        {
            string output = "";
            TextWriter consoleOut = Console.Out;
            try
            {
                if (this.assembly != null)
                {
                    Thread exeThread = new Thread(new ThreadStart(this.runStandardJob));
                    Job job = new Job();
                    job.Name = methodName;
                    job.Args.AddRange(args);
                    this.threadJobs[exeThread] = job;
                    exeThread.IsBackground = true;
                    exeThread.Start();
                    exeThread.Join(5000);//join when done or in 5 sec.

                    output = (string)this.threadJobs[exeThread].Result;

                    this.threadJobs[exeThread] = null;//clean up the thread job
                }
            }
            catch { }
            finally
            {
                Console.SetOut(consoleOut);
            }
            return output;
        }
Пример #3
0
 public bool ExecuteCondition(string id, Hashtable vars)
 {
     try
     {
         if(!this.conditions.ContainsKey(id))
         {
             return true;
         }
         else if(this.assembly != null)
         {
             Thread exeThread = new Thread(new ThreadStart(this.runCondition));
             Job job = new Job();
             job.Name = this.COND_PREFIX + id;
             job.Args.Add(new StringTable(vars));
             this.threadJobs[exeThread] = job;
             exeThread.IsBackground = true;
             exeThread.Start();
             exeThread.Join(5000);//join when done or in 5 sec.
             bool result = (bool)this.threadJobs[exeThread].Result;
             this.threadJobs[exeThread] = null;//clean up the thread job
             return result;
         }
     }
     catch{}
     return false;//error
 }