Esempio n. 1
0
    public void Run()
    {
        while (ActiveProcess.Status == ComputerStatus.Running || ActiveProcess.Status == ComputerStatus.Waiting ||
               WaitingProcesses.Keys.ToList().Any())
        {
            if (ActiveProcess.Status == ComputerStatus.Running)
            {
                ActiveProcess.Start();
            }
            else if (ActiveProcess.Status == ComputerStatus.Waiting)
            {
                SetSharedMemory(ActiveProcess.DumpOutput());
                WaitingProcesses.Add(ActiveProcess.WaitingSince, ActiveProcess.Identifier);
                ActiveProcess = GetLongestWaitingProcess();
                ActiveProcess.setInput(GetSharedMemory(ActiveProcess.Identifier));
            }
            else
            {
                SetSharedMemory(ActiveProcess.DumpOutput());
                ActiveProcess = GetLongestWaitingProcess();
                ActiveProcess.setInput(GetSharedMemory(ActiveProcess.Identifier));
            }
        }

        LastOutput = ActiveProcess.DumpOutput().Item1;
    }
Esempio n. 2
0
        private IList <ActiveProcess> GetProcesses()
        {
            var result = new List <ActiveProcess>();

            Process.GetProcesses().ToList().ForEach(p =>
            {
                var activeProccess = new ActiveProcess()
                {
                    Id       = p.Id,
                    Name     = p.ProcessName,
                    Priority = p.BasePriority,
                    Memory   = p.PrivateMemorySize64
                };
                result.Add(activeProccess);
            });
            return(result);
        }
Esempio n. 3
0
 /// <summary>
 ///   Exits from current process or from current call. If called directly from a process
 ///   body, then the process is stopped and the optional exit value can be found on <see
 ///   cref="SimProcess.Value"/>. Otherwise, if this method is called from a procedure body,
 ///   then the procedure is stopped and the optional exit value can be found on the event
 ///   returned by <see cref="Call"/>.
 /// </summary>
 /// <param name="value">The optional exit value.</param>
 /// <returns>The exit event that can be yielded to stop a process or a call.</returns>
 public SimEvent Exit(object value)
 {
     ActiveProcess.SetExitValue(value);
     return(EndEvent);
 }
Esempio n. 4
0
 /// <summary>
 ///   Exits from current process or from current call. If called directly from a process
 ///   body, then the process is stopped and the optional exit value can be found on <see
 ///   cref="SimProcess.Value"/>. Otherwise, if this method is called from a procedure body,
 ///   then the procedure is stopped.
 /// </summary>
 /// <returns>The exit event that can be yielded to stop a process or a call.</returns>
 public SimEvent Exit()
 {
     ActiveProcess.SetExitValue(Default.Value);
     return(EndEvent);
 }