virtual public byte ThreadExecuteCommand(String command, int repeat, int delay, List <Object> args)
        {
            //check has command
            ArduinoCommand acmd = GetCommand(command);

            if (acmd == null)
            {
                throw new Exception(String.Format("Device {0} does not have command {1}", ID, command));
            }

            //pass an empty array rather than null ... safety measure here just for the ThreadExecution Manager
            if (args == null)
            {
                args = new List <Object>();
            }

            byte tag = acmd.ExpectsResponse ? Mgr.MessageTags.CreateTag() : (byte)0;
            ExecutionArguments xargs = new ExecutionArguments(args, tag);

            //Use ThreadExecutionManager to allow for multi-threading by device
            int prevSize = ThreadExecutionManager.MaxQueueSize;

            ThreadExecutionManager.MaxQueueSize = acmd.IsCompound ? 1 : 256;
            ThreadExecutionState xs = ThreadExecutionManager.Execute <ExecutionArguments>(ID, repeat, delay, ExecuteCommand, command, xargs);

            ThreadExecutionManager.MaxQueueSize = prevSize;
            if (xs == null)
            {
                Mgr.MessageTags.Release(tag);
                tag = 0;
            }

            return(tag);
        }
        protected void Start(Action action, int retryAttempts = 3)
        {
            String monitorId = "Monitor-" + ID;
            int    attempts  = 0;

            while (true)
            {
                if (ThreadExecutionManager.IsEmpty(ID) && ThreadExecutionManager.IsEmpty(monitorId))
                {
                    _startXS = ThreadExecutionManager.Execute(ID, action);
                    if (_startXS == null)
                    {
                        throw new Exception("Connection::Start: Unable to create thread for connection " + ID);
                    }
                    _monitorXS = ThreadExecutionManager.Execute(monitorId, this.Monitor);
                    Tracing?.TraceEvent(TraceEventType.Verbose, 2000, "Connection::Start: Created execution thread {0} and monitor thrad{1}", ID, monitorId);

                    break;
                }
                else
                {
                    if (++attempts > retryAttempts)
                    {
                        var sxs = ThreadExecutionManager.GetExecutionState(ID);
                        var mxs = ThreadExecutionManager.GetExecutionState(monitorId);
                        throw new Exception("Thread ID " + ID + " has state " + sxs.State + " and " + monitorId + " has state " + mxs.State);
                    }
                    System.Threading.Thread.Sleep(200);
                }
            }
        }
Beispiel #3
0
        private static void Main(string[] args)
        {
            if (!Directory.Exists(Tas.Directory))
            {
                Directory.CreateDirectory(Tas.Directory);
            }
            if (File.Exists(Path.Combine(Tas.Directory, "Debug Log.txt")))
            {
                File.Delete(Path.Combine(Tas.Directory, "Debug Log.txt"));
            }
            Logger.Clear();

            // copy alsoft.ini because
            try
            {
                File.Copy("alsoft.ini", Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "alsoft.ini"), true);
            }
            catch (Exception ex)
            {
                Logger.Log("alsoft.ini", LogSeverity.Error, ex.ToString());
            }

            try
            {
                ApplyArgs(args);
            }
            catch (Exception e)
            {
                Logger.Log("args", LogSeverity.Error, e.ToString());
            }

            Logger.Try(Run);
            Logger.Log("FEZ", "Exiting.");

            try
            {
                ThreadExecutionState.TearDown();
            }
            catch (Exception ex)
            {
                Logger.Log("ThreadExecutionState", ex.ToString());
            }
        }
Beispiel #4
0
        public Fez()
        {
            ThreadExecutionState.SetUp();
            DateTime dateTime = Fez.RetrieveLinkerTimestamp();

            Logger.Log("Version", Fez.Version + ", Build Date : " + dateTime.ToShortDateString() + " " + dateTime.ToShortTimeString());
            if (!CommunityExpress.Instance.Initialize())
            {
                int num = (int)MessageBox.Show("This version of FEZ needs Steam to be running.\r\nPlease make sure an instance of Steam is active before starting the game.", "Error", MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Hand);
                this.Exit();
                this.IsDisposed = true;
            }
            else
            {
                this.deviceManager            = new GraphicsDeviceManager((Game)this);
                SettingsManager.DeviceManager = this.deviceManager;
                this.Content.RootDirectory    = "Content";
                Guide.SimulateTrialMode       = Fez.TrialMode;
                ServiceHelper.Game            = (Game)this;
                ServiceHelper.IsFull          = true;
            }
        }
 internal static extern ThreadExecutionState SetThreadExecutionState(ThreadExecutionState esFlags);
Beispiel #6
0
 public static void SetThreadExecutionState(ThreadExecutionState state)
 {
     NativeMethods.SetThreadExecutionState((uint)state);
 }
 private static extern uint SetThreadExecutionState(ThreadExecutionState esFlags);