后台过程控制 [英] Background Process control

查看:118
本文介绍了后台过程控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助我..



如何在Windows应用程序处理无限循环条件时停止后台进程

Pls help me ..

How to stop the background process when it is processing infinite loop condition in windows Application

   Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork

    While True
        TextBox1.Text = Val(Val(TextBox1.Text) + 1).ToString()
    End While

End Sub

推荐答案

有很多东西都带有代码,这不好笑。



Frist,你滥用这个词处理。那不是后台进程,它是后台线程。进程和线程意味着非常不同的东西。



接下来,您无法从后台线程触摸UI控件(在您的情况下为TextBox)。



您必须使用相同TextBox的值更新TextBox的值,这使得输入任何有用的东西几乎不可能。



将字符串转换为字符串再转换为字符串只是精神错乱。







你想要做什么?因为无论如何,你做错了什么!
There are so many things worn gwith that code it's not funny.

Frist, you're misusing the term "process". That's not a background process, it's a background thread. Processes and threads mean very different things.

Next, you cannot touch a UI control (TextBox in your case) from a backgrtound thread.

You're CONSTANTLY updating the value of a TextBox with the value of the same TextBox, making it pretty much impossible to type anything useful in it.

The conversion of a string to a value to a string and back to a value again is just insanity.



What are you trying to really do?? Because whatever it is, you're doing everything wrong!


这篇关于后台过程控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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