长活动指标控制 [英] Long activity indicator control

查看:72
本文介绍了长活动指标控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一个用c#v1.1开发的winforms应用程序。

该应用程序有一个调用webservice方法的表单。从GUI线程内部执行调用

,可能需要一分钟。

同时,我想向用户提供某种可视指示符

表示应用程序未被冻结。

对WS的调用应保留在GUI线程上,因为我不想要

用户当电话处于

效果时操纵其他视觉控制。

我不需要显示进度条,只是某种动态

图片如下:
https:// marketplace.slizone.com/SliM...es/loading.gif

或其他播放动态内容的用户控件。

任何想法如何执行这个?

谢谢。

Hi

I have a winforms application developed in c# v1.1.
The application has a form that calls a webservice method. The call is
performed from inside the GUI thread and may take up to a minute.
Meanwhile, I want to provide to the user some sort of visual indicator
indicating that the application is not frozen.
The call to the WS should remain on the GUI thread, as I don''t want
the user to manipulate other visual controls while the call is in
effect.
I don''t need to display a progress bar, just some sort of a dynamic
image like this:
https://marketplace.slizone.com/SliM...es/loading.gif
or another user control that plays some dynamic content.
Any idea how to perform this?
Thanks.

推荐答案

11月12日下午3:22,nano2k< adrian .rot ... @ ikonsoft.rowrote:
On Nov 12, 3:22 pm, nano2k <adrian.rot...@ikonsoft.rowrote:

我ha在c#v1.1中开发的winforms应用程序。

应用程序有一个调用webservice方法的表单。从GUI线程内部执行调用

,可能需要一分钟。
I have a winforms application developed in c# v1.1.
The application has a form that calls a webservice method. The call is
performed from inside the GUI thread and may take up to a minute.



在GUI线程上执行此操作并不是一个好主意。

Doing that on a GUI thread is not a good idea.


同时,我想提供向用户提供某种可视指示符

表示应用程序未被冻结。

对WS的调用应保留在GUI线程上,因为我不是想要

用户操纵其他视觉控制,而电话是在

效果。
Meanwhile, I want to provide to the user some sort of visual indicator
indicating that the application is not frozen.
The call to the WS should remain on the GUI thread, as I don''t want
the user to manipulate other visual controls while the call is in
effect.



然后在操作过程中禁用这些控件。你不能在UI线程上进行长时间的调用。

Then disable those controls while the operation is in progress. You
shouldn''t make a long-running call on the UI thread.


我不需要显示进度吧,这是一个像这样的动态

图像: https://marketplace.slizone.com/SliM...es/loading.gif

或其他播放动态内容的用户控件。

知道如何执行此操作吗?
I don''t need to display a progress bar, just some sort of a dynamic
image like this:https://marketplace.slizone.com/SliM...es/loading.gif
or another user control that plays some dynamic content.
Any idea how to perform this?



我会认真考虑禁用UI线程上的所有控件,然后

然后在其他地方进行调用,更新UI进度

指标(任何形式,无论是否是图像)都适当。


我知道这很痛苦,但锁定了一分钟的UI线程是一个非常糟糕的想法。


Jon

I would seriously look at disabling all controls on the UI thread, and
then making the call elsewhere, updating the UI with a progress
indicator (of any kind, whether that''s an image or not) appropriately.

I know it''s a pain, but locking up the UI thread for a minute is a
really bad idea.

Jon


作为Jon表示的附加内容(好建议),您可以将动画gif

放入图片框控件中,并在通话时打开Visible属性

制作。当结果返回时,您将使图片不可见。但是你不希望

从UI线程进行web服务调用。

- Peter
http://www.eggheadcafe.com

unBlog: http://petesbloggerama.blogspot.com

BlogMetaFinder: http://www.blogmetafinder.com

" nano2k"写道:
As an add-on to what Jon indicated (good advice), you can put an animated gif
into a picturebox control and turn on the Visible property when the call is
made. When results come back, you make the pic invisible. But you do not want
to make your webservice call from the UI thread.
-- Peter
http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com

"nano2k" wrote:




我有一个用c#v1.1开发的winforms应用程序。

应用程序具有调用Web服务方法的表单。从GUI线程内部执行调用

,可能需要一分钟。

同时,我想向用户提供某种可视指示符

表示应用程序未被冻结。

对WS的调用应保留在GUI线程上,因为我不想要

用户当电话处于

效果时操纵其他视觉控制。

我不需要显示进度条,只是某种动态

图片如下:
https:// marketplace.slizone.com/SliM...es/loading.gif

或其他播放动态内容的用户控件。

任何想法如何执行这个?

谢谢。

Hi

I have a winforms application developed in c# v1.1.
The application has a form that calls a webservice method. The call is
performed from inside the GUI thread and may take up to a minute.
Meanwhile, I want to provide to the user some sort of visual indicator
indicating that the application is not frozen.
The call to the WS should remain on the GUI thread, as I don''t want
the user to manipulate other visual controls while the call is in
effect.
I don''t need to display a progress bar, just some sort of a dynamic
image like this:
https://marketplace.slizone.com/SliM...es/loading.gif
or another user control that plays some dynamic content.
Any idea how to perform this?
Thanks.


12 Noi,17:25,Jon Skeet [C#MVP ]" < sk ... @ pobox.comwrote:
On 12 Noi, 17:25, "Jon Skeet [C# MVP]" <sk...@pobox.comwrote:

11月12日下午3:22,nano2k< adrian.rot ... @ ikonsoft.rowrote:
On Nov 12, 3:22 pm, nano2k <adrian.rot...@ikonsoft.rowrote:

我有一个用c#v1.1开发的winforms应用程序。

应用程序有一个调用webservice方法的表单。从GUI线程内部执行调用

,可能需要一分钟。
I have a winforms application developed in c# v1.1.
The application has a form that calls a webservice method. The call is
performed from inside the GUI thread and may take up to a minute.



在GUI线程上执行此操作并不是一个好主意。


Doing that on a GUI thread is not a good idea.


同时,我想提供向用户提供某种可视指示符

表示应用程序未被冻结。

对WS的调用应保留在GUI线程上,因为我不是想要

用户操纵其他视觉控制,而电话是在

效果。
Meanwhile, I want to provide to the user some sort of visual indicator
indicating that the application is not frozen.
The call to the WS should remain on the GUI thread, as I don''t want
the user to manipulate other visual controls while the call is in
effect.



然后在操作过程中禁用这些控件。你不能在UI线程上进行长时间的调用。


Then disable those controls while the operation is in progress. You
shouldn''t make a long-running call on the UI thread.


我不需要显示进度吧,这是一个像这样的动态

图像: https://marketplace.slizone.com/SliM...es/loading.gif

或其他播放动态内容的用户控件。

知道如何执行此操作吗?
I don''t need to display a progress bar, just some sort of a dynamic
image like this:https://marketplace.slizone.com/SliM...es/loading.gif
or another user control that plays some dynamic content.
Any idea how to perform this?



我会认真考虑禁用UI线程上的所有控件,然后

然后在其他地方拨打电话,更新UI进度

指标(任何形式,无论是否是图像)都适当。


我知道这很痛苦,但锁定了一分钟的UI线程是一个非常糟糕的想法。


Jon


I would seriously look at disabling all controls on the UI thread, and
then making the call elsewhere, updating the UI with a progress
indicator (of any kind, whether that''s an image or not) appropriately.

I know it''s a pain, but locking up the UI thread for a minute is a
really bad idea.

Jon



你好

谢谢

为什么这么糟糕?我看到的唯一不好的一面是GUI

在通话过程中不会被绘制。

实际上,在99%的时间内,通话不会超过
秒(它只对用户进行身份验证),但是,比如说,当WS离线时,
离线时,调用将花费足够长的时间直到异常弹出,

所以这个电话应该给用户一些视觉信号。

是不是有一种方法可以强制部分GUI从

另一个线程?

从另一个线程尝试过这个(当然是使用Invoke()),但没有

运气。


再次感谢。

Hi
Thanks
Why is it such a bad idea? The only bad side I see is that the GUI
won''t get painted while the call is in progress.
Actually, in 99% of the times, the call will not take more than a
second (it only authenticates the user), but, say, when the WS is
offline, the call will take long enough until the exception pops up,
so the call deserves some sort of visual signal to the user.
Isn''t there a method of forcing a portion of the GUI to update from
another thread?
Tried this from another thread (using Invoke(), of course), but no
luck.

Thanks again.


这篇关于长活动指标控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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