帮助线程池??? [英] Help Thread pooling ???

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

问题描述

亲爱的,


我有一个我需要在一个线程中运行的函数,因为它可以

需要很长时间才能执行根据要收集的数据量。

此功能还填充了一个树形视图控件,当收集的数据完成后,

完成。


为了实现这个目的,我使用了以下代码:

System.Threading.ThreadPool.QueueUserWorkItem(New

System.Threading.WaitCallback(AddressOf GetListOfReelsFromRemoteDB))

===>>

private sub GetListOfReelsFromRemoteDB

m_objRemoteHist =新的远程(m_sRemoteDbPath)

m_objRemoteHist.Read()

Dim sParam(0)As Object


sParam(0)= m_objRemoteHist

tLogView.Invoke(AddReels,sParam)

Me.Cursor = Cursors.Default

end sub

<< ===


Read例程,co从远程数据库中选择数据

当Read返回时,它使用调用使用delagate对象填充树视图控件




我遇到的问题是当tLogView.Invoke(AddReels,sparam)执行时,它会释放我的整个应用程序并获得无响应状态。我猜那里

shuld线程队列过程有问题,但不知道为什么

以及如何解决它


有没有人可以帮忙?


问候

serge

Dear all,

I have a function that I need to run in a thread due to the fact that it can
takes long time to execute according to the amount of data to collect.
This function is also populating a treeview control whne collected data gets
finished.

In order to achieve this I have used the following code :
System.Threading.ThreadPool.QueueUserWorkItem(New
System.Threading.WaitCallback(AddressOf GetListOfReelsFromRemoteDB))

Then my function definition is as follow :

===>>
private sub GetListOfReelsFromRemoteDB
m_objRemoteHist = New Remote(m_sRemoteDbPath)

m_objRemoteHist.Read()
Dim sParam(0) As Object

sParam(0) = m_objRemoteHist
tLogView.Invoke(AddReels, sParam)
Me.Cursor = Cursors.Default
end sub
<<===

The Read routine, collect data froma remote database
When Read return, it populates a tree view control with a delagate object by
using the Invoke.

Problem I have is that when tLogView.Invoke(AddReels,sparam) execute, it
frees my whole application and gets "no responding status". I guess there
shuld be something wrong with the thread queue process but do not know why
and how to solve it

Does anyone could help ?

regards
serge

推荐答案

必要的调用Invoke会导致树视图的更新在

表格的主题上执行。这意味着用户界面将无法响应,而由于主线程正忙,因此正在填充树视图。


如果您希望用户界面更具响应性您可能想尝试更改

代码,以便为每个项目调用一次Invoke,而不是为所有

项目调用一次。这将为主线程提供额外的时间来更新UI调用Invoke之间的UI

。您可能需要添加一些代码来处理

情况,其中用户在填充树时关闭表单。


HTH,Jakob。

-
http://www.dotninjas.dk
http://www.powerbytes.dk

serge calderara写道:
The necessary call to Invoke causes the update of the treeview to execute on
the thread of your form. This means that the UI will be unresponsive while
the treeview is being populated because the main thread is busy.

If you want the UI to be more responsive you might want to try changing the
code so that Invoke is called once for each item instead of once for all
items. This will give the main thread a little extra time to update the UI
inbetween the calls to Invoke. You may have to add some code to handle the
case where the user closes the form while the tree is being populated.

HTH, Jakob.
--
http://www.dotninjas.dk
http://www.powerbytes.dk
"serge calderara" wrote:
亲爱的,

我有一个功能,我需要在一个线程中运行,因为它可以
需要很长时间根据要收集的数据量执行的时间。
此功能还填充了一个收集的数据完成后的树视图控件。

为了达到这个目的,我使用了以下代码:
System.Threading.ThreadPool.QueueUserWorkItem(New
System.Threading.WaitCallback(AddressOf GetListOfReelsFromRemoteDB))

然后我的函数定义如下:

===>>
私人子GetListOfReelsFromRemoteDB
m_objRemoteHist =新远程(m_sRemoteDbPath)

m_objRemoteHist.Read()
Dim sParam( 0)作为对象

sParam(0)= m_objRemoteHist
tLogView.Invoke(AddReels,sParam)
Me.Cursor = Cursors.Default
end sub << ===

Read例程,从远程数据库收集数据
当Read返回时,它使用调用使用delagate对象填充树视图控件。

我遇到的问题是当tLogView.Invoke时( AddReels,sparam)执行,它释放我的整个应用程序并获得无响应状态。我猜那里有线程排队过程有问题,但不知道为什么
以及如何解决它

有人可以提供帮助吗?
问候
serge
Dear all,

I have a function that I need to run in a thread due to the fact that it can
takes long time to execute according to the amount of data to collect.
This function is also populating a treeview control whne collected data gets
finished.

In order to achieve this I have used the following code :
System.Threading.ThreadPool.QueueUserWorkItem(New
System.Threading.WaitCallback(AddressOf GetListOfReelsFromRemoteDB))

Then my function definition is as follow :

===>>
private sub GetListOfReelsFromRemoteDB
m_objRemoteHist = New Remote(m_sRemoteDbPath)

m_objRemoteHist.Read()
Dim sParam(0) As Object

sParam(0) = m_objRemoteHist
tLogView.Invoke(AddReels, sParam)
Me.Cursor = Cursors.Default
end sub
<<===

The Read routine, collect data froma remote database
When Read return, it populates a tree view control with a delagate object by
using the Invoke.

Problem I have is that when tLogView.Invoke(AddReels,sparam) execute, it
frees my whole application and gets "no responding status". I guess there
shuld be something wrong with the thread queue process but do not know why
and how to solve it

Does anyone could help ?

regards
serge



我会试一试。

BUt那么你怎么解释我的申请是冻结了否

回应永远,即使我的caollected数据是一个简单而独特的行

????


仅为了您的信息,我没有执行我的功能一个红色的游泳池,

很明显我的主要形式是diturbed但它永远不会冻结

thnaks为你提供帮助


Jakob Christensen写道:
I will give a try.
BUt then how do you explain that my application is freezed with" No
responding" for ever even if my caollected data is a simple and unique row
????

Just for your information, I i am not executing my function in a thred pool,
its clear that my main form is diturbed but it is not freeze at all for ever
thnaks for your help

"Jakob Christensen" wrote:
对Invoke的必要调用导致树视图的更新在
表单的线程上执行。这意味着在构建树视图时UI将无法响应,因为主线程正忙。

如果您希望UI响应更快,您可能想尝试更改
代码,以便为每个项目调用一次Invoke,而不是为所有
项目调用一次。这将使主线程在调用Invoke之间更新UI。您可能需要添加一些代码来处理用户在填充树时关闭表单的情况。

HTH,Jakob。
-
http://www.dotninjas.dk
http://www.powerbytes.dk

" serge calderara"写道:
The necessary call to Invoke causes the update of the treeview to execute on
the thread of your form. This means that the UI will be unresponsive while
the treeview is being populated because the main thread is busy.

If you want the UI to be more responsive you might want to try changing the
code so that Invoke is called once for each item instead of once for all
items. This will give the main thread a little extra time to update the UI
inbetween the calls to Invoke. You may have to add some code to handle the
case where the user closes the form while the tree is being populated.

HTH, Jakob.
--
http://www.dotninjas.dk
http://www.powerbytes.dk
"serge calderara" wrote:
亲爱的,

我有一个功能,我需要在一个线程中运行,因为它可以
需要很长时间根据要收集的数据量执行的时间。
此功能还填充了一个收集的数据完成后的树视图控件。

为了达到这个目的,我使用了以下代码:
System.Threading.ThreadPool.QueueUserWorkItem(New
System.Threading.WaitCallback(AddressOf GetListOfReelsFromRemoteDB))

然后我的函数定义如下:

===>>
私人子GetListOfReelsFromRemoteDB
m_objRemoteHist =新远程(m_sRemoteDbPath)

m_objRemoteHist.Read()
Dim sParam( 0)作为对象

sParam(0)= m_objRemoteHist
tLogView.Invoke(AddReels,sParam)
Me.Cursor = Cursors.Default
end sub << ===

Read例程,c远程数据库中的ollect数据
当Read返回时,它使用调用使用delagate对象填充树视图控件。

我遇到的问题是当tLogView.Invoke时( AddReels,sparam)执行,它释放我的整个应用程序并获得无响应状态。我猜那里有线程排队过程有问题,但不知道为什么
以及如何解决它

有人可以提供帮助吗?
问候
serge
Dear all,

I have a function that I need to run in a thread due to the fact that it can
takes long time to execute according to the amount of data to collect.
This function is also populating a treeview control whne collected data gets
finished.

In order to achieve this I have used the following code :
System.Threading.ThreadPool.QueueUserWorkItem(New
System.Threading.WaitCallback(AddressOf GetListOfReelsFromRemoteDB))

Then my function definition is as follow :

===>>
private sub GetListOfReelsFromRemoteDB
m_objRemoteHist = New Remote(m_sRemoteDbPath)

m_objRemoteHist.Read()
Dim sParam(0) As Object

sParam(0) = m_objRemoteHist
tLogView.Invoke(AddReels, sParam)
Me.Cursor = Cursors.Default
end sub
<<===

The Read routine, collect data froma remote database
When Read return, it populates a tree view control with a delagate object by
using the Invoke.

Problem I have is that when tLogView.Invoke(AddReels,sparam) execute, it
frees my whole application and gets "no responding status". I guess there
shuld be something wrong with the thread queue process but do not know why
and how to solve it

Does anyone could help ?

regards
serge



我只是尝试你的建议在每个节点使用调用但它冻结了

立刻永远。


一旦Invoke行开始执行就冻结

我确实被卡住了。

" Jakob Christensen"写道:
I just try your suggestion use the invoke at each node but it freeze
immediatly for ever.

It freeze as soon as the Invoke line start to be executed
I am stuck indeed out of idea.
"Jakob Christensen" wrote:
对Invoke的必要调用导致树视图的更新在
表单的线程上执行。这意味着在构建树视图时UI将无法响应,因为主线程正忙。

如果您希望UI响应更快,您可能想尝试更改
代码,以便为每个项目调用一次Invoke,而不是为所有
项目调用一次。这将使主线程在调用Invoke之间更新UI。您可能需要添加一些代码来处理用户在填充树时关闭表单的情况。

HTH,Jakob。
-
http://www.dotninjas.dk
http://www.powerbytes.dk

" serge calderara"写道:
The necessary call to Invoke causes the update of the treeview to execute on
the thread of your form. This means that the UI will be unresponsive while
the treeview is being populated because the main thread is busy.

If you want the UI to be more responsive you might want to try changing the
code so that Invoke is called once for each item instead of once for all
items. This will give the main thread a little extra time to update the UI
inbetween the calls to Invoke. You may have to add some code to handle the
case where the user closes the form while the tree is being populated.

HTH, Jakob.
--
http://www.dotninjas.dk
http://www.powerbytes.dk
"serge calderara" wrote:
亲爱的,

我有一个功能,我需要在一个线程中运行,因为它可以
需要很长时间根据要收集的数据量执行的时间。
此功能还填充了一个收集的数据完成后的树视图控件。

为了达到这个目的,我使用了以下代码:
System.Threading.ThreadPool.QueueUserWorkItem(New
System.Threading.WaitCallback(AddressOf GetListOfReelsFromRemoteDB))

然后我的函数定义如下:

===>>
私人子GetListOfReelsFromRemoteDB
m_objRemoteHist =新远程(m_sRemoteDbPath)

m_objRemoteHist.Read()
Dim sParam( 0)作为对象

sParam(0)= m_objRemoteHist
tLogView.Invoke(AddReels,sParam)
Me.Cursor = Cursors.Default
end sub << ===

Read例程,c远程数据库中的ollect数据
当Read返回时,它使用调用使用delagate对象填充树视图控件。

我遇到的问题是当tLogView.Invoke时( AddReels,sparam)执行,它释放我的整个应用程序并获得无响应状态。我猜那里有线程排队过程有问题,但不知道为什么
以及如何解决它

有人可以提供帮助吗?
问候
serge
Dear all,

I have a function that I need to run in a thread due to the fact that it can
takes long time to execute according to the amount of data to collect.
This function is also populating a treeview control whne collected data gets
finished.

In order to achieve this I have used the following code :
System.Threading.ThreadPool.QueueUserWorkItem(New
System.Threading.WaitCallback(AddressOf GetListOfReelsFromRemoteDB))

Then my function definition is as follow :

===>>
private sub GetListOfReelsFromRemoteDB
m_objRemoteHist = New Remote(m_sRemoteDbPath)

m_objRemoteHist.Read()
Dim sParam(0) As Object

sParam(0) = m_objRemoteHist
tLogView.Invoke(AddReels, sParam)
Me.Cursor = Cursors.Default
end sub
<<===

The Read routine, collect data froma remote database
When Read return, it populates a tree view control with a delagate object by
using the Invoke.

Problem I have is that when tLogView.Invoke(AddReels,sparam) execute, it
frees my whole application and gets "no responding status". I guess there
shuld be something wrong with the thread queue process but do not know why
and how to solve it

Does anyone could help ?

regards
serge



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

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