一个严重的线程问题 [英] A serious Threading Problem

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

问题描述



大家好,

首先让我让问题变得通用!

我有三个功能A(),B( )& C()。

从主函数函数我按顺序调用它们 -

公共函数MyMain()

A()

B()

C()

结束函数


B()shuold在A之后执行()& C()应该在B()之后执行。

但我的问题是只将B()放入子线程中。

我想要放B()在subthread中,因为我在A()中创建UI并且

希望它在执行B()时对用户事件进行重新定位。

我们如何判断C( )除非B()完成否则不执行?


请帮助,

提前致谢,


- 问候,

Dinesh


***通过Developersdex发送 http://www.developersdex.com ***

不要只是参加USENET ......获得奖励!


Hi All,
First of all let me make the problem generic!
I have three function A(),B() & C().
From main function function I call them in sequence like this -
public function MyMain()
A()
B()
C()
End Function

B() shuold be executed after A() & C() should be executed after B().
But my problem is is to put only B() in a subthread.
I want B() to be put in a subthread because I create UI in A() and
want it to be resposive for user events when B() is being executed.
How can we tell C() not te execute unless B() finishes?

Please help,
Thanks in advance,

-Regards,
Dinesh

*** Sent via Developersdex http://www.developersdex.com ***
Don''t just participate in USENET...get rewarded for it!

推荐答案

如果你把func C放在一个线程中,检查条件或共享变量

共享变量的值将为true如果B已经完成


在C里面,你可以使用while循环


而真实

如果sharedvar =真的

完成我的任务......


循环


伙计们,如果我错了,请纠正我

但这看起来很简单


Kalpesh

If you put func C in a thread, check for a condition or a shared variable
The value of the shared variable will be true if B has finished

Inside C, you can use a while loop

while true
if sharedvar = true
do my task...

loop

Guys, correct me if I am wrong
But this looks like a easy way out

Kalpesh


您好Kalpesh,

Thnax回复。

在C()中放置一个while循环将使应用程序停止

挂起直到B()结束,这将导致while循环停止。

此外,放入循环将消耗大部分CPU使用。

我想我将不得不处理这些社区,

还有更多想法吗?

Thnaks提前,


-Regards,

Dinesh


***通过Developersdex发送 http://www.developersdex.com ***

不要只是参加USENET ...获得奖励!
Hi Kalpesh,
Thnax for reply.
Putting a while loop inside C() will cuase the application
hang till B() finishes which will cause the while loop to be stopped.
Moreover, putting while loop will consume most of the CPU useage.
I think I will have to deal with thead-communiactions,
Any more ideas?
Thnaks in advance,

-Regards,
Dinesh

*** Sent via Developersdex http://www.developersdex.com ***
Don''t just participate in USENET...get rewarded for it!


为什么不创建一个单独的函数d(),它运行在子线程中

调用c()然后调用d()??

问候

Simon

" Dinesh Jain" <二******* @ hotmail.com>在消息中写道

news:eN ************** @ TK2MSFTNGP10.phx.gbl ...
why not create a seperate function d() which is runs in a subthread which
calls c() and then d()??

Regards
Simon
"Dinesh Jain" <di*******@hotmail.com> wrote in message
news:eN**************@TK2MSFTNGP10.phx.gbl...
嗨Kalpesh,
回复的Thnax。
在C()中放置一个while循环将使应用程序挂起
挂起直到B()结束,这将导致while循环停止。
此外,放入循环将消耗大部分CPU使用。
我想我将不得不处理这些社区,
还有更多的想法吗?
预先提醒,

- 问候,
Dinesh

***通过开发人员指南 http:/ /www.developersdex.com ***
不要只是参加USENET ......获得奖励!
Hi Kalpesh,
Thnax for reply.
Putting a while loop inside C() will cuase the application
hang till B() finishes which will cause the while loop to be stopped.
Moreover, putting while loop will consume most of the CPU useage.
I think I will have to deal with thead-communiactions,
Any more ideas?
Thnaks in advance,

-Regards,
Dinesh

*** Sent via Developersdex http://www.developersdex.com ***
Don''t just participate in USENET...get rewarded for it!



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

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