帮助 - 时序逻辑 [英] Help - Timing Logic

查看:52
本文介绍了帮助 - 时序逻辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个多线程VB.NET应用程序(4个线程),用于通过system.timer在5秒内向许多员工发送

短信

区间。基本上,我查看一个SQL表(队列)来确定谁需要

来接收文本消息然后将消息发送到该地址。只有

的问题是,员工最多可以收到4条相同的消息,因为

每个线程获得recors然后发送消息。我需要以某种方式

防止这种情况......我想不出怎么做。不知怎的,我需要其他线程

知道另一个线程已经在使用该记录并转到

下一条记录。我想到记录然后标记它(列值)

在使用中并编写代码以查找仅在未使用的记录...

问题是所有4个运行得足够快,所有人都使用/标记该行。有什么想法吗?


非常感谢。


Jay

I have a multi threaded VB.NET application (4 threads) that I use to send
text messages to many, many employees via system.timer at a 5 second
interval. Basically, I look in a SQL table (queue) to determine who needs
to receive the text message then send the message to the address. Only
problem is, the employee may receive up to 4 of the same messages because
each thread gets the recors then sends the message. I need somehow to
prevent this... just can''t think of how. Somehow I need the other threads
to know that another thread is already using that record and move on to the
next record. I thought of getting the record then marking it (column value)
as in use and writing the code to look for records only where not in use...
problem is all 4 run fast enough to all use/mark the row. Any thoughts?

Thanks a lot.

Jay

推荐答案

在类或模块中使用全局属性。


public IsRunning as boolean


如果设置为true,则设置为true如果没有,则设置为false。


您仍然可以触发线程,但是处理暂停将

属性设置为true。 />

例子


私人子工作()

如果IsRunning = true则

退出子

其他

工作
Use a global property in the class or a module.

public IsRunning as boolean

Set to true if running, set to false if not.

You can still fire the threads, but have the processing pause will the
property is set to true.

Example

Private sub Do Work()
If IsRunning = true then
exit sub
else
Work


谢谢。我仍然需要所有4个进程来从表中获取一行。

只有当一个线程已经有一行时,接下来的3个线程才能使用

相同的行。

" Ryan S. Thiele" < ma ***** @ verizon.netwrote in message

news:GaYah.14096
Thanks. I still need all 4 processes working to get a row from the table.
Only if one thread already has a row then the next 3 threads cant use the
same row.
"Ryan S. Thiele" <ma*****@verizon.netwrote in message
news:GaYah.14096


LH2.13672@trndny04 ...
LH2.13672@trndny04...

在类或模块中使用全局属性。


public IsRunning as boolean


如果不运行则设置为true,否则设置为false。


您仍然可以触发线程,但是处理暂停将设置

属性真实。


例子


私人子工作()

如果IsRunning = true则

退出子

其他

工作





结束如果

结束子


这有用吗?

-

-

Thiele Enterprises - 权力掌握在你手中!

-

" Jay" < so ***** @ somewhere.comwrote in message

news:O2 ************** @ TK2MSFTNGP04.phx.gbl ...

我有一个多线程VB.NET应用程序(4个线程),用于通过system.timer在5秒内向许多员工发送

短信
区间。基本上,我查看一个SQL表(队列)来确定谁需要

来接收文本消息然后将消息发送到该地址。只有

的问题是,员工最多可以收到4条相同的消息,因为

每个线程获得recors然后发送消息。我需要以某种方式

防止这种情况......我想不出怎么做。不知怎的,我需要其他线程

知道另一个线程已经在使用该记录并转移到

下一条记录。我想要记录然后标记它(列

值)

在使用中并编写代码以查找仅在不在
$ b中的记录$ b使用...

问题是所有4运行得足够快以便所有人使用/标记该行。有什么想法吗?


非常感谢。


Jay

Use a global property in the class or a module.

public IsRunning as boolean

Set to true if running, set to false if not.

You can still fire the threads, but have the processing pause will the
property is set to true.

Example

Private sub Do Work()
If IsRunning = true then
exit sub
else
Work
.
.
end if
end sub

Does this work?
--
--
Thiele Enterprises - The Power Is In Your Hands Now!
--
"Jay" <so*****@somewhere.comwrote in message
news:O2**************@TK2MSFTNGP04.phx.gbl...
I have a multi threaded VB.NET application (4 threads) that I use to send
text messages to many, many employees via system.timer at a 5 second
interval. Basically, I look in a SQL table (queue) to determine who needs
to receive the text message then send the message to the address. Only
problem is, the employee may receive up to 4 of the same messages because
each thread gets the recors then sends the message. I need somehow to
prevent this... just can''t think of how. Somehow I need the other threads
to know that another thread is already using that record and move on to
the
next record. I thought of getting the record then marking it (column
value)
as in use and writing the code to look for records only where not in
use...
problem is all 4 run fast enough to all use/mark the row. Any thoughts?

Thanks a lot.

Jay


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

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