亚洲一级电影在线观看,九九精品无码专区免费,亚洲AV无码资源在线观看 ,欧美国产高清

Winform多線程方式登錄代碼

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

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

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

  bool restart = true;

  while (restart)

  {

  Start(out restart);

  }

  (1):在主進程中不停的調(diào)用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("錄入登錄信息發(fā)生異常,請和管理員聯(lián)系", 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;

  //結(jié)束執(zhí)行

  Splasher.EndExecute(previousStepResult);

  }

  catch (Exception error)

  {

  //略

  }

  }

  }

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

  static public void Show()

  {

  try

  {

  //當?shù)诙握{(diào)用的時候MySplashThread != null了這個時候

  if (MySplashThread != null)

  {

  // public void Reset()

  //{

  // progressView.Reset();

  //currentItemIndex = 0;

  //}

  //相當于觸發(fā)MySplashForm.Reset事件。

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

  //將窗體顯示出來。

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

  return;

  }

  //當?shù)谝淮蔚臅r候調(diào)用構(gòu)造函數(shù)構(gòu)造出窗體。構(gòu)造出來以后myResetEvent.Set();通知

  if (MySplashForm == null)

  {

  MySplashForm = new LoginProcessForm(myResetEvent);

  }

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

  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);

  }

  }

  //構(gòu)造函數(shù)。

  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)

  {

  //回調(diào)會繼續(xù)執(zhí)行previousProcessResult,等下次的時候就會到下面去執(zhí)行了。

  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;

  }

  }

【W(wǎng)inform多線程方式登錄代碼】相關文章:

Java多線程的實現(xiàn)方式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代碼優(yōu)化技巧09-24

主站蜘蛛池模板: 中文字幕人乱码中文字幕| 亚洲成av人片无码不卡| 亚欧av无码乱码在线观看性色| 潮喷失禁大喷水aⅴ无码| 亚洲伊人久久综合影院| 亚洲熟妇国产熟妇肥婆| 久热这里只有精品99在线观看 | 欧洲精品码一区二区三区| 可以直接免费观看的av网站| 国内精品自产拍在线观看| 无码丰满人妻熟妇区| 丰满少妇在线观看网站| 免费无码午夜福利片69| 国产主播av福利精品一区| 亚洲www啪成人一区二区麻豆| 国产内射老熟女aaaa∵| 久久久亚洲欧洲日产国产成人无码| 廊坊市| 亚洲国产初高中生女av| 九九在线中文字幕无码| 午夜成人影片av| 临泽县| 久久中文字幕日韩精品| 国产女人喷水视频| 精品欧美一区二区三区在线| 毛片视频网址| 青草娱乐极品免费视频| 国产中文视频| 国产成人精品高清在线观看99| 亚洲国产精品久久久久网站| 国产精品多人p群无码| 伊人成色综合网| 国产乱子伦精品无码码专区| 无码东京热一区二区三区| 2012中文字幕在线视频| 国产亚洲精品久久www| 夏津县| 日韩第一页在线| 国产激爽大片高清在线观看| 国产精品国产三级国产av品爱网| 欧美日韩中文国产一区发布|