在登录表单上显示等待图标 [英] show wait icon on login form

查看:60
本文介绍了在登录表单上显示等待图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨所有

i想要在登录表单上显示一个图片框作为'等待登录消息'并显示WaitForloginPicturebox,我运行一个新的线程如下代码:

hi all
i want to show a picture box on login form as 'wait for login message' and to show WaitForloginPicturebox ,I run a new thread like below code:

Thread t;
void ShowWaitImage()
{
    if (WaitForloginPicturebox .InvokeRequired)
    {
       this.WaitForloginPicturebox .Invoke(new MethodInvoker(ShowWaitImage));
    }
    else
    {
        this.pictureBox2.Visible = true;
    }
}
private void button1_Click(object sender, EventArgs e)
{
    t=new Thread(new ThreadStart(ShowWaitImage));
    t.Start();
    //...
}



但它没有显示这个。(不工作)


but it doesn't show this.(Not Working)

推荐答案

它不起作用,因为你无法触摸来自后台线程的UI,或UI(启动)线程以外的任何线程。将您的登录代码放在后台线程中,并将UI内容保留在启动线程上。
It won't work because you cannot touch the UI from a background thread, or any thread other than the UI (startup) thread. Put your login code in the background thread and keep the UI stuff on the startup thread.


我相信您是递归调用相同的方法(ShowWaitImage)。你永远不会逃离if ... else
I believe you are invoking the same method (ShowWaitImage) recursively. You never escape from the first part of the if...else


这篇关于在登录表单上显示等待图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆