关于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();// oginInfo();
if (userInfo == null)
{
loginOK = false;
return;
}
//启动登陆后台线程。LoginProcessForm窗体启动MySplashThread启动不停的打开LoginProcessForm窗体。
();
}
catch (Exception err)
{
e(err);
Dialog("录入登录信息发生异常,请和管理员联系", r);
return;
}
eProcessState previousStepResult = lete;
while (tExecute())
{
try
{
switch (entStep)
{
case eLoginState.__:
case eLoginState.__:
case eLoginState.__:
case eLoginState.__:
}
previousStepResult = lete;
//结束执行
xecute(previousStepResult);
}
catch (Exception error)
{
//略
}
}
}
//start中的对过程的控制。
static public void Show()
{
try
{
//当第二次调用的时候MySplashThread != null了这个时候
if (MySplashThread != null)
{
// public void Reset()
//{
// t();
//currentItemIndex = 0;
//}
//相当于触发t事件。
ke(new MethodInvoker(t));
//将窗体显示出来。
ke(new MethodInvoker());
return;
}
//当第一次的时候调用构造函数构造出窗体。构造出来以后();通知
if (MySplashForm == null)
{
MySplashForm = new LoginProcessForm(myResetEvent);
}
//这里只是每次都调用(MySplashForm);作用相当于建立起信息循环队列
MySplashThread = new Thread(new ThreadStart(Thread));
ckground = true;
partmentState();
t();
//等待直到();
One(5000);
}
catch (Exception err)
{
e(err);
}
}
//构造函数。
public LoginProcessForm(AutoResetEvent autoreset)
{
myResetEvent = autoreset;
Renderer = new SkinFormLoginFormRender();
InitializeComponent();
//ost = true;
//eBox = true;
CanMoveWindow = false;
= "Version:" + mblyFileVersion;
+= new EventHandler(LoginProcessForm_Load);
}
delegate void EndExecuteCallback(eProcessState previousProcessResult);
static public void EndExecute(eProcessState previousProcessResult)
{
//winform中子线程不能更新主线程的`控件。所以keRequired代表是否需要更新主线程控件。
//如果需要更新的话ke
if (keRequired)
{
//回调会继续执行previousProcessResult,等下次的时候就会到下面去执行了。
ke(new EndExecuteCallback(EndExecute), previousProcessResult);
}
else
{
//如果
xecute(previousProcessResult);
}
}
///
/// 进入下一过程
///
///
///
public void EndExecute(eProcessState previousProcessResult)
{
//progressView为我们使用的用户控件
ip(processItems[currentItemIndex], previousProcessResult);
currentItemIndex++;
}
//关闭代码
static public void Close()
{
try
{
if (MySplashThread == null) return;
if (MySplashForm == null) return;
try
{
ke(new MethodInvoker(e));
}
catch (Exception err)
{
e(err);
}
t();
}
catch (Exception err)
{
e(err);
}
finally
{
MySplashThread = null;
MySplashForm = null;
}
}
相關文章
-
word提示Microsoft Office Word已停止工作的解决方法
系统更新了几个补丁,提示重启,因为当时正在工作,就没有立即重启,开着WORD,后来出去一会儿,回来后发现已经自动重启了,打开WORD发现有两个保存的文件,打开一个继续工作,也不记得是保存的时候还是关闭的时候发现提示OFFICE WORD -
如何破解winRAR加密文件 Microsoft Word 文档
1. 新建一个文本文件txt,word也行,然后F2重命名为“”;2. 用记事本打开,将以下横线中的代码复制到文件中并保存; —————————————————————————— RAR registration dataFederal Agency for Educati -
Never Put Off anything Until Tomorrow 今日事今日毕英语作文
We have been told that mever put lff untill tomorrow what you can do today since childhood. However, there are still many people who like putting offthc things thcv should do today until tomorrow. The -
Should women work after marriage英语作文
在日常的学习、工作、生活中,许多人都写过作文吧,借助作文可以宣泄心中的情感,调节自己的心情。你知道作文怎样才能写的.好吗?以下是小编收集整理的Should women work after marriage英语作文,仅供参考,希望能够帮助到大家 -
英语演讲稿:Working for a short time
working for a short time ifind that people is the most important thing in the world without people nothing can our life is very important must value our life as we value our should not only work ha -
Office办公Word多栏页码设置技巧
在日常使用电脑的过程中,Word的使用最普遍,因此基本上大家对Word都比较熟悉,但是有些时候个别的特殊需要还真难倒了我们。例如在Word文档中设置了分栏后,尽管一页中有两栏或者多栏文字,但使用插入页码命令,却只能在该页中插 -
OFFICE2007每次打开word时都显示配置microsoft office professio
Office 2007每次打开都要出现配置Microsoft Office Professional Plus 2007双击excel文件出现如下提示:然后提示:点击确定出现:而上一步若点击取消,则提示: 问题解决: 方法一:首先用360和诺顿都查了一遍,无木马或病毒。参 -
brought rain in April Mayflowe英语作文
from the golden-tipped fields of mid-west america to the ancient kingdoms of verdant palestine, there is a happy truth to be shared with all who would take heed. in more recent times, this truth has b -
朗文双语口语教程Form morning to night从早到晚
导语:从早上到晚上,我们会经历很多事情,下面是关于从早到晚的朗文双语口语教程,欢迎大家来学习。"Exactly Ed"这就是EdAt exactly 6:45,Ed gets up.6;45的时候,Ed起床了。He's Exactly Ed.他就是Ed。At exactly 7:00,E -
should women work after getting married英语作文
在平时的学习、工作或生活中,大家都接触过作文吧,作文是通过文字来表达一个主题意义的记叙方法。你知道作文怎样才能写的好吗?以下是小编为大家收集的should women work after getting married英语作文,欢迎大家借鉴与参