形成计时器,事件和线程 [英] forms timers, events, and threading

查看:67
本文介绍了形成计时器,事件和线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的WinForms应用程序在单个默认线程上运行,并为所有查询使用单个

SqlConnection对象。我需要使用一个或多个计时器来定期执行其中一些计时器。我自己的测试表明,表单

定时器不能在自己的线程上运行,并且不会导致查询被发送以使用单个SqlConnection而另一个正在执行从

处理其他事件。是对的吗?我只想在做出这个设计之前100%确定




Bob

My WinForms app runs on the single default thread, and uses a single
SqlConnection object for all queries. I need to use one or more timers to
periodically execute some of them. My own testing indicates that the forms
timer does not operate on its own thread and will not cause a query to be
sent to use the single SqlConnection while another is being executed from
the handling of other events. Is that right? I just want to be 100% sure
before I commit to this design.

Bob

推荐答案

Bob,


我不完全确定你的问题,但是一个线程每次操作只能执行一次

操作。因此,当长时间进行SQL操作时,通过实例进行数据适配器更新,而不是首先进行更新,然后才能获取

计时器事件。


我希望这有帮助吗?


Cor


" Bob" < no *** @ nowhere.com>

...
Bob,

I am not completly sure of your question, however a thread does only one
operation per operation. So when there is a longtime taking SQL operation
by instance a dataadapter update, than that will first be done, before the
timer event is catched.

I hope this helps?

Cor

"Bob" <no***@nowhere.com>
...
我的WinForms应用程序在单个默认线程上运行,并使用单个
SqlConnection对象对于所有查询。我需要使用一个或多个计时器来定期执行其中一些计时器。我自己的测试表明,表单
定时器不能在自己的线程上运行,并且不会导致查询被发送以使用单个SqlConnection,而另一个正在执行的处理其他事件。是对的吗?我只想在做出这个设计之前100%确定

鲍勃
My WinForms app runs on the single default thread, and uses a single
SqlConnection object for all queries. I need to use one or more timers to
periodically execute some of them. My own testing indicates that the forms
timer does not operate on its own thread and will not cause a query to be
sent to use the single SqlConnection while another is being executed from
the handling of other events. Is that right? I just want to be 100% sure
before I commit to this design.

Bob



Bob,


但是在我忘记它之前,为什么你不测试这类问题

当它如此重要时。一个小的测试程序在我的意见中很快

足够吗?


sub Myprocedure Y

threading.thread.sleep(4000 )

end sub


子计时器

通过将timertick设置为1000毫秒来测试是否抛出

end sub


Cor


" Bob" < no *** @ nowhere.com>

...
Bob,

However before I forget it, why do you not test this kind of questions
yourself when it is so important. A small test program is in my opinon fast
enough made?

sub Myprocedure Y
threading.thread.sleep(4000)
end sub

sub Timer
test if it is throw by setting the timertick to 1000 miliseconds
end sub

Cor

"Bob" <no***@nowhere.com>
...
我的WinForms应用程序在单个默认线程上运行,并使用单个
SqlConnection对象对于所有查询。我需要使用一个或多个计时器来定期执行其中一些计时器。我自己的测试表明,表单
定时器不能在自己的线程上运行,并且不会导致查询被发送以使用单个SqlConnection,而另一个正在执行的处理其他事件。是对的吗?我只想在做出这个设计之前100%确定

鲍勃
My WinForms app runs on the single default thread, and uses a single
SqlConnection object for all queries. I need to use one or more timers to
periodically execute some of them. My own testing indicates that the forms
timer does not operate on its own thread and will not cause a query to be
sent to use the single SqlConnection while another is being executed from
the handling of other events. Is that right? I just want to be 100% sure
before I commit to this design.

Bob



你显然错过了我自己的测试。我的消息的一部分。


Bob


" Cor Ligthert" <无************ @ planet.nl>在消息中写道

news:OM ************** @ TK2MSFTNGP09.phx.gbl ...
You obviously missed the "my own testing" part of my message.

Bob

"Cor Ligthert" <no************@planet.nl> wrote in message
news:OM**************@TK2MSFTNGP09.phx.gbl...
Bob,
然而,在我忘记它之前,为什么当它如此重要时你不要自己测试这类问题。一个小小的测试程序在我的意见中是
足够快了吗?

sub Myprocedure Y
threading.thread.sleep(4000)
end sub

子计时器测试是否通过将timertick设置为1000毫秒来抛出

Cor
Bob,

However before I forget it, why do you not test this kind of questions
yourself when it is so important. A small test program is in my opinon fast enough made?

sub Myprocedure Y
threading.thread.sleep(4000)
end sub

sub Timer
test if it is throw by setting the timertick to 1000 miliseconds
end sub

Cor



这篇关于形成计时器,事件和线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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