Пример #1
0
        private void FormClientMain_Load(object sender, EventArgs args)
        {
            Resource.TLog.Log((int)ELogItem.Note, "Start Calorimeter Client Program.");
            DispCaption();

            DefMenu.Index = 0;
            Location      = new Point(0, 0);

            Resource.TLog.Log((int)ELogItem.Note, "Resume the thread for listener.");
            Resource.Client.Resume();

            Resource.TLog.Log((int)ELogItem.Note, "Send connection command to Server.");
            Resource.Client.Connect();

            Resource.TLog.Log((int)ELogItem.Note, "Resume invalidation thread of screen.");
            invalidThread = new InvalidThread(csInvalidTime);
            invalidThread.InvalidControls += InvalidForm;
            invalidThread.Resume();

            Resource.TLog.Log((int)ELogItem.Note, "Resume TestContext threads");
            CtrlTestLeft ctrlLeft = DefMenu.Controls((int)EMainMenuItem.Test) as CtrlTestLeft;

            for (int i = 0; i < ctrlLeft.DefMenu.ControlsCount; i++)
            {
                CtrlTestRight ctrlRight = ctrlLeft.DefMenu.Controls(i) as CtrlTestRight;
                ctrlRight.Context.Resume();
            }

            SetUser();
        }
Пример #2
0
        private void FormClientMain_FormClosed(object sender, FormClosedEventArgs e)
        {
            Resource.State = EClientState.Closing;

            Resource.TLog.Log((int)ELogItem.Note, "Terminate TestContext threads");
            CtrlTestLeft ctrlLeft = DefMenu.Controls((int)EMainMenuItem.Test) as CtrlTestLeft;

            for (int i = 0; i < ctrlLeft.DefMenu.ControlsCount; i++)
            {
                CtrlTestRight ctrlRight = ctrlLeft.DefMenu.Controls(i) as CtrlTestRight;
                ctrlRight.Context.Terminate();
            }

            if (invalidThread.IsAlive == true)
            {
                Resource.TLog.Log((int)ELogItem.Note, "Terminate an invalid thread");
                invalidThread.Terminate();
            }

            switch (terminateCode)
            {
            case ETerminateCode.None:
                Resource.Client.Disconnect();
                break;

            case ETerminateCode.ReceivedTerminateCommand:
                MessageBox.Show("This program is terminated by termination command from server!",
                                Resource.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                break;

            case ETerminateCode.NonAcknowledgement:
                //MessageBox.Show("This program is terminated by non acknowledgement from server!",
                //    Resource.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                break;
            }

            Resource.TLog.Log((int)ELogItem.Note, "Terminate a client threads");
            Resource.Client.Terminate();

            Resource.TLog.Log((int)ELogItem.Note, "Exit Calorimeter Client Program");
        }