从e.Result获取数据时出现问题 [英] Problem in getting data from e.Result

查看:182
本文介绍了从e.Result获取数据时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在使用后台工作程序从TCP/IP端口获取数据. do work方法从TCP/IP端口成功获取数据,并通过e.Result传递到主线程.在工作完成的方法中,我将e.Result分配给文本框控件.但是我看不到文本框中的数据.甚至我都可以使用手表在调试模式下在文本框控件的Text属性中看到数据,但数据不会显示在屏幕上的文本框中.

这是代码.

Hi
I am using background worker to fetch data from TCP/IP port. The do work method gets data successfully from TCP/IP port and passes to main thread through e.Result. In work-completed method i assign the e.Result to a text box control. But i can not see the data in text box. Even i can see data in the Text property of the textbox control in the debug mode using watches but it is not displayed in the text box on the screen.

Here is the code.

private void bgWCardIn_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
            
                if (e.Cancelled)
                {

                }
                else
                {
                         if (e.Result != null)
                         {
                              this.txtCardNo.Text = e.Result.ToString();
                         }
                        
                    
                         this.bgWCardIn.RunWorkerAsync();  
                }  
}



我从e.Result获取数据后重新启动后台工作器

使用该行



I restart the background worker after getting data from e.Result

using the line

this.bgWCardIn.RunWorkerAsync();



在此先谢谢您.



Thanks in advance.

推荐答案

奇怪的解决方案-但请确保您没有两个文本框一个接一个.
这可能就是为什么您看不到文本的原因.
另外,通过代码刷新/重新绘制表单一次.
Weird solution - but make sure you don''t have two textboxes one on top of the other.
This may be why you are not seeing the text.

Also, refresh / repaint your form once via code.


这篇关于从e.Result获取数据时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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