回到主题 [英] Back to Threads

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

问题描述

大家好,


我现在正试图通过工作人员

线程上的Timer控件来更新状态指示器。状态指示器只是主窗体上的标签,但是我很难确定如何实现单独的工作程序

线程或异步委托更改标签内容基于

计时器控件的标记。那里有什么好的例子,你可以吗?
把我指向一两个?


谢谢,

Michael C.

解决方案

似乎问题是在SqlClient上发出SqlCommands似乎

完全接管当前线程。我以为我可以通过一个简单的Timer控件在UI线程上完成这一切,但这不会发生在''。关于如何在SqlCommand期间让我的Timer控件切换到
执行的任何

想法?这将是一个比单独的线程更简单和更好的解决方案。但如果有必要的话,我愿意接受一个单独的工作线程。


提前谢谢,

Michael C.


Michael C < MI ******* @ optonline.net>在消息中写道

news:y2 ********************** @ news4.srv.hcvlny.cv。 net ...

大家好,我现在正试图通过
工作线程上的Timer控件更新状态指示器。状态指示器只是主窗体上的标签,但是我很难确定如何实现单独的工作线程或异步委托,根据$ b $更改标签内容b Timer控制器的滴答声。那里有什么好的例子,你能指点我一两个吗?

谢谢,
Michael C.



嗨Michael,


看到这篇好文章(有3个部分)

Windows中安全,简单的多线程表格
http://msdn.microsoft.com/library/de...ms06112002.asp


-

Miha Markic [MVP C#] - RightHand .NET咨询&开发

miha at rthand com
www.rthand.com


" Michael C" < MI ******* @ optonline.net>在消息中写道

news:y2 ********************** @ news4.srv.hcvlny.cv。 net ...

大家好,我现在正试图通过
工作线程上的Timer控件更新状态指示器。状态指示器只是主窗体上的标签,但是我很难确定如何实现单独的工作线程或异步委托,根据$ b $更改标签内容b Timer控制器的滴答声。那里有什么好的例子,你能指点我一两个吗?

谢谢,
Michael C.



感谢您的链接。他的书中有相同的示例代码(Windows

C#中的表单编程)。问题是它没有解决我的实际问题,

这就是我正在执行的SQL查询似乎阻止了Timer()控件

Tick事件从执行。即使我在

单独的线程上运行状态更新代码,就像在他的书中一样......我如何让我的Timer()勾选为

它应该是到?


谢谢,

Michael C.


Miha Markic [MVP C#]" < miha at rthand com>在消息中写道

news:up ************** @ tk2msftngp13.phx.gbl ...

嗨Michael,

看到这篇好文章(有3个部分)
Windows窗体中安全,简单的多线程
http://msdn.microsoft.com/library/de...ms06112002.asp
-
Miha Markic [MVP C#] - RightHand .NET咨询&开发
miha at rthand com
www.rthand.com

Michael C < MI ******* @ optonline.net>在消息中写道
新闻:y2 ********************** @ news4.srv.hcvlny.cv。 net ...

大家好,

我现在正试图通过


worker <上的Timer控件更新状态指示器blockquote class =post_quotes> thread。状态指示器只是主窗体上的标签,但是我很难确定如何实现单独的工作线程或异步委托,它根据

计时器控件'的滴答声。那里有没有好的例子,你可以用
把我指向一两个?

谢谢,
Michael C.




Hi all,

I''m now trying to update a status indicator via a Timer control on a worker
thread. The status indicator is just a label on the main form, but I''m
having trouble figuring out exactly how to implement a separate worker
thread or asynchronous delegate that changes the label contents based on the
Timer control''s ticks. Are there any good examples out there and can you
point me to one or two?

Thanks,
Michael C.

解决方案

It seems that the issue is that issuing SqlCommands on a SqlClient seems to
take over the current thread completely. I thought I could do this all on
the UI thread with a simple Timer control, but that ain''t happenin''. Any
ideas on how I can get my Timer control to Tick during SqlCommand
executions? That would be a much simpler and preferable solution than a
separate thread. But I''m open to a separate worker thread if necessary.

Thanks in advance,
Michael C.

"Michael C" <mi*******@optonline.net> wrote in message
news:y2**********************@news4.srv.hcvlny.cv. net...

Hi all,

I''m now trying to update a status indicator via a Timer control on a worker thread. The status indicator is just a label on the main form, but I''m
having trouble figuring out exactly how to implement a separate worker
thread or asynchronous delegate that changes the label contents based on the Timer control''s ticks. Are there any good examples out there and can you
point me to one or two?

Thanks,
Michael C.



Hi Michael,

See this fine article (there are 3 parts)
Safe, Simple Multithreading in Windows Forms
http://msdn.microsoft.com/library/de...ms06112002.asp

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"Michael C" <mi*******@optonline.net> wrote in message
news:y2**********************@news4.srv.hcvlny.cv. net...

Hi all,

I''m now trying to update a status indicator via a Timer control on a worker thread. The status indicator is just a label on the main form, but I''m
having trouble figuring out exactly how to implement a separate worker
thread or asynchronous delegate that changes the label contents based on the Timer control''s ticks. Are there any good examples out there and can you
point me to one or two?

Thanks,
Michael C.



Thanks for the link. He has the same example code in his book (Windows
Forms Programming in C#). Problem is that it doesn''t solve my real problem,
which is that the SQL Query I''m executing seems to block the Timer() control
Tick event from ever executing. Even when I run the status update code on a
separate thread like in his book... How can I make my Timer() Tick like
it''s supposed to?

Thanks,
Michael C.

"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:up**************@tk2msftngp13.phx.gbl...

Hi Michael,

See this fine article (there are 3 parts)
Safe, Simple Multithreading in Windows Forms
http://msdn.microsoft.com/library/de...ms06112002.asp
--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"Michael C" <mi*******@optonline.net> wrote in message
news:y2**********************@news4.srv.hcvlny.cv. net...

Hi all,

I''m now trying to update a status indicator via a Timer control on a


worker

thread. The status indicator is just a label on the main form, but I''m
having trouble figuring out exactly how to implement a separate worker
thread or asynchronous delegate that changes the label contents based on


the

Timer control''s ticks. Are there any good examples out there and can you point me to one or two?

Thanks,
Michael C.




这篇关于回到主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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