Esempio n. 1
0
        public void Dispose()
        {
            if (FormUI != null)
            {
                FormUI.FormClosed -= UserInterface_Closed;
                FormUI.Close();
                FormUI = null;
            }
            else if (WindowUI != null)
            {
                WindowUI.Closed -= UserInterface_Closed;
                WindowUI.Close();
                WindowUI = null;
            }
            else if (Instance != null)
            {
                Instance.Dispose();
            }

            IEnumerable <TaskCompletionSource <HPacket> > handledDataSources = DataAwaiters.Values.ToArray();

            foreach (TaskCompletionSource <HPacket> handledDataSource in handledDataSources)
            {
                handledDataSource.SetResult(null);
            }

            Instance     = null;
            CurrentState = DISPOSED_STATE;
        }