Exemplo n.º 1
0
        //the ignore connection flag will prevent reinitilization of the connection if the connection is not null
        public async Task Start(bool ignoreconn)
        {
            if (expconn != null && !ignoreconn)
            {
                await Stop();
            }

            if (expconn == null)
            {
                expconn = new LocalExpanderConnection(connprop);
            }

            //write the base state
            ExpanderState bs_copy;

            lock (base_state_lock)
                bs_copy = new ExpanderState(base_state);

            await WriteExpanders(new bool[] { true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true },
                                 new bool[] { true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true },
                                 bs_copy.Expander0State,
                                 bs_copy.Expander1State);

            monitor_task = GenerateMonitor();
            monitor_task.Start();
        }
Exemplo n.º 2
0
        public async Task Stop(bool ignoreconn)
        {
            if (monitor_task != null)
            {
                monitor_stop = true;
                while (monitor_task.Status == TaskStatus.Running)
                {
                    await Task.Delay(100);
                }
            }

            if (expconn != null && !ignoreconn)
            {
                while (expconn.Busy)
                {
                    await Task.Delay(100);
                }
                expconn.Stop();
                expconn = null;
            }

            lock (expander_state_lock)
                expst = null;
        }