中文字幕在线一区二区在线,久久久精品免费观看国产,无码日日模日日碰夜夜爽,天堂av在线最新版在线,日韩美精品无码一本二本三本,麻豆精品三级国产国语,精品无码AⅤ片,国产区在线观看视频

      Winform多線程方式登錄代碼

      時間:2024-10-10 19:18:57 ACCP培訓 我要投稿
      • 相關推薦

      關于Winform多線程方式登錄代碼

        為了方便大家學習相關的知識,YJBYS小編下面為你整理了關于Winform多線程方式登錄代碼,希望對你有所幫助。

        bool restart = true;

        while (restart)

        {

        Start(out restart);

        }

        (1):在主進程中不停的調用start.

        void Start(out bool restart)

        {

        bool connected = false;

        restart = false;

        string[] userInfo = null;

        try

        {

        //打開LoginInfoForm窗體,返回用戶名密碼。

        userInfo = GetLoginInfo();// Splasher.GetLoginInfo();

        if (userInfo == null)

        {

        loginOK = false;

        return;

        }

        //啟動登陸后臺線程。LoginProcessForm窗體啟動MySplashThread啟動不停的打開LoginProcessForm窗體。

        Splasher.Show();

        }

        catch (Exception err)

        {

        DebugHelper.Write(err);

        Splasher.ShowDialog("錄入登錄信息發生異常,請和管理員聯系", MessageTipType.Error);

        return;

        }

        eProcessState previousStepResult = eProcessState.Complete;

        while (Splasher.StartExecute())

        {

        try

        {

        switch (Splasher.CurrentStep)

        {

        case eLoginState.__:

        case eLoginState.__:

        case eLoginState.__:

        case eLoginState.__:

        }

        previousStepResult = eProcessState.Complete;

        //結束執行

        Splasher.EndExecute(previousStepResult);

        }

        catch (Exception error)

        {

        //略

        }

        }

        }

        //start中的對過程的控制。

        static public void Show()

        {

        try

        {

        //當第二次調用的時候MySplashThread != null了這個時候

        if (MySplashThread != null)

        {

        // public void Reset()

        //{

        // progressView.Reset();

        //currentItemIndex = 0;

        //}

        //相當于觸發MySplashForm.Reset事件。

        MySplashForm.Invoke(new MethodInvoker(MySplashForm.Reset));

        //將窗體顯示出來。

        MySplashForm.Invoke(new MethodInvoker(MySplashForm.Show));

        return;

        }

        //當第一次的時候調用構造函數構造出窗體。構造出來以后myResetEvent.Set();通知

        if (MySplashForm == null)

        {

        MySplashForm = new LoginProcessForm(myResetEvent);

        }

        //這里只是每次都調用Application.Run(MySplashForm);作用相當于建立起信息循環隊列

        MySplashThread = new Thread(new ThreadStart(Splasher.ShowThread));

        MySplashThread.IsBackground = true;

        MySplashThread.SetApartmentState(ApartmentState.STA);

        MySplashThread.Start();

        //等待直到myResetEvent.Set();

        myResetEvent.WaitOne(5000);

        }

        catch (Exception err)

        {

        DebugHelper.Write(err);

        }

        }

        //構造函數。

        public LoginProcessForm(AutoResetEvent autoreset)

        {

        myResetEvent = autoreset;

        Renderer = new SkinFormLoginFormRender();

        InitializeComponent();

        //this.TopMost = true;

        //this.CloseBox = true;

        CanMoveWindow = false;

        labelVersion.Text = "Version:" + AssemblyInfoHelper.AssemblyFileVersion;

        this.Load += new EventHandler(LoginProcessForm_Load);

        }

        delegate void EndExecuteCallback(eProcessState previousProcessResult);

        static public void EndExecute(eProcessState previousProcessResult)

        {

        //winform中子線程不能更新主線程的控件。所以MySplashForm.InvokeRequired代表是否需要更新主線程控件。

        //如果需要更新的話MySplashForm.Invoke

        if (MySplashForm.InvokeRequired)

        {

        //回調會繼續執行previousProcessResult,等下次的時候就會到下面去執行了。

        MySplashForm.Invoke(new EndExecuteCallback(EndExecute), previousProcessResult);

        }

        else

        {

        //如果

        MySplashForm.EndExecute(previousProcessResult);

        }

        }

        ///

        /// 進入下一過程

        ///

        ///

        ///

        public void EndExecute(eProcessState previousProcessResult)

        {

        //progressView為我們使用的用戶控件

        progressView.SetTip(processItems[currentItemIndex], previousProcessResult);

        currentItemIndex++;

        }

        //關閉代碼

        static public void Close()

        {

        try

        {

        if (MySplashThread == null) return;

        if (MySplashForm == null) return;

        try

        {

        MySplashForm.Invoke(new MethodInvoker(MySplashForm.Close));

        }

        catch (Exception err)

        {

        DebugHelper.Write(err);

        }

        MySplashThread.Abort();

        }

        catch (Exception err)

        {

        DebugHelper.Write(err);

        }

        finally

        {

        MySplashThread = null;

        MySplashForm = null;

        }

        }

      【Winform多線程方式登錄代碼】相關文章:

      Java多線程的實現方式07-08

      顯示jquery代碼的四種方式06-26

      PHP Curl多線程原理詳解09-11

      HTML的代碼注釋10-07

      過濾HTML代碼08-29

      關于MyEclipse代碼提示設置包括html和jsp的代碼09-25

      java多線程面試題201710-03

      asp緩存類代碼09-28

      關于AJAX類代碼09-19

      PHP代碼優化技巧09-24

      主站蜘蛛池模板: 亚洲成人激情在线影院| 国产精品亚洲专区一区二区| 亚洲性69影视| 久久99老妇伦国产熟女高清| 国产精品亚洲一区二区毛片| 日韩啪啪精品一区二区亚洲av| 人妻无码中文专区久久AV| 国产粉嫩美女一区二区三| 国产在线看不卡一区二区 | 久久久诱惑一区二区三区| 99久久亚洲精品加勒比| 日本一区二区三区看片| 中文字幕乱码免费人妻av| 久久免费看少妇a级作爱片| 无遮挡粉嫩小泬| 一级少妇无遮掩内射免费| 无码精品国产午夜| 国产精品白浆免费观看| 咸丰县| 国产精品污一区二区三区| 中文字幕在线视频不卡一区二区| 五月天婷婷一区二区三区久久| AV在线毛片| 日本女优中文字幕在线观看| 日本一区二区三区中文字幕最新 | 亚洲av毛片成人精品| 久久精品中文字幕久久| 在线毛片一区二区不卡视频| 国产精品剧情一区二区三区av| 中超| 中文字幕在线观看乱码一区| 宁河县| 日韩丝袜人妻中文字幕| 国产成人精品cao在线| 辽阳县| 久久国产精品免费一区六九堂| 曲沃县| 午夜爽毛片| 蜜桃视频在线免费观看一区二区| 河西区| 99国产精品无码专区|