473,396 Members | 2,140 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

UI not responding

I have a UI thread not responding also.

I have an Async operation that I am processing a long running SQL script
in ADO.Net. I am executing the Command asynchronous and hooking the
SqlCommand.StatementCompleted. I then use AsyncOperation to post events
back to the UI thread. The UI thread then updates a progress bar and
multi-line textbox. I then send a Windows Message to auto scroll the
textbox to the bottom. When the script stops running the UI comes back
to life.

The problem:
Sometimes when the user scrolls the textbox the UI thread locks-up.

What I’ve tried:
I have done extensive testing on my Async class on the execution path,
events and the logic.
The trace statements show the events firing, and being fully handled.
I tried commenting out the auto scroll, but that did not fix it.

What I think the problem is:
Honestly I don’t know.
The trace statements show everything is working correctly and executing
on the correct thread.

Is it possible to overload the application with too many events so the
UI can’t update?

The size of the project makes it very difficult in posting some examples
(Main form 900loc, SQL processor 800loc & Async base 500loc). So I am
just looking for some ideas on how to fix this problem.

Thanks
sprayer

*** Sent via Developersdex http://www.developersdex.com ***
Jun 7 '06 #1
6 4098
My advice is to create a small app and attempt to recreate the issue.
It doesn't sound like it would be too difficult and it would make it
much easier for us (you included) to diagnose the problem.
sprayer wrote:
I have a UI thread not responding also.

I have an Async operation that I am processing a long running SQL script
in ADO.Net. I am executing the Command asynchronous and hooking the
SqlCommand.StatementCompleted. I then use AsyncOperation to post events
back to the UI thread. The UI thread then updates a progress bar and
multi-line textbox. I then send a Windows Message to auto scroll the
textbox to the bottom. When the script stops running the UI comes back
to life.

The problem:
Sometimes when the user scrolls the textbox the UI thread locks-up.

What I've tried:
I have done extensive testing on my Async class on the execution path,
events and the logic.
The trace statements show the events firing, and being fully handled.
I tried commenting out the auto scroll, but that did not fix it.

What I think the problem is:
Honestly I don't know.
The trace statements show everything is working correctly and executing
on the correct thread.

Is it possible to overload the application with too many events so the
UI can't update?

The size of the project makes it very difficult in posting some examples
(Main form 900loc, SQL processor 800loc & Async base 500loc). So I am
just looking for some ideas on how to fix this problem.

Thanks
sprayer

*** Sent via Developersdex http://www.developersdex.com ***


Jun 7 '06 #2
Ya am able to reproduce the freeze regularly now. I made a SQL script
that affects ~8000 rows individually. This produced 8000 events to be
raised back to the main UI thread to handle (This is an extreme case,
but it reproduces the error). So I am sending so many events back to
the main UI thread its bogging it down.

What is the best practice for high throughput & chatty asynchronous
process?

I’m using “System.ComponentModel.AsyncOperation.Post()” to raise the
events on the UI thread. So I am thinking to not use AsyncOperation and
post the event on the asynchronous thread and then switch to the UI
thread only to update the user controls. Not sure but I think I will
have the same problem.

Thanks for the reply
sprayer
MCAD.NET
*** Sent via Developersdex http://www.developersdex.com ***
Jun 8 '06 #3
A trick you can use here is to batch the updates at the UI; set a timer
going when you start the async work, and stop it when it completes; when you
get the events, chuck the "updates" (in some form) into a collection
(remembering to lock it first); when the (slower) timer-tick fires [on the
UI thread], lock the same collection and read the "updates" into an array,
then clear the collection and unlock it; (this allows the events to keep
going while you update the UI); now loop through the collection of "updates"
and fix the UI, ideally using BeginUpdate/EndUpdate, SuspendLayout and
ResumeLayout to maximise throughput.

Oh - and remember a final sweep of the collection after stopping the timer
(after the async has ended).

That any help?

Marc
Jun 8 '06 #4
oh - and by "updates" I meant the vague term of whatever it is you need to
know... perhaps the specific event-type, sender and event-args on a holding
class?

Marc
Jun 8 '06 #5
The best practice is to increase the interval at which you report
progress. Does your client really need to know when .01% of the work is
done? Probably not.

sprayer wrote:
Ya am able to reproduce the freeze regularly now. I made a SQL script
that affects ~8000 rows individually. This produced 8000 events to be
raised back to the main UI thread to handle (This is an extreme case,
but it reproduces the error). So I am sending so many events back to
the main UI thread its bogging it down.

What is the best practice for high throughput & chatty asynchronous
process?

I'm using "System.ComponentModel.AsyncOperation.Post()" to raise the
events on the UI thread. So I am thinking to not use AsyncOperation and
post the event on the asynchronous thread and then switch to the UI
thread only to update the user controls. Not sure but I think I will
have the same problem.

Thanks for the reply
sprayer
MCAD.NET
*** Sent via Developersdex http://www.developersdex.com ***


Jun 8 '06 #6
If you run a task that updates the UI at such a high frequency, there is no
reason to run it on a separate thread, unless you run this on a SMP or
multi-core. Just run the task on the UI thread, this saves you from burning
a mass of CPU cycles only to marshal the update to the UI thread.

Willy.

"sprayer" <an*******@devdex.com> wrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
| Ya am able to reproduce the freeze regularly now. I made a SQL script
| that affects ~8000 rows individually. This produced 8000 events to be
| raised back to the main UI thread to handle (This is an extreme case,
| but it reproduces the error). So I am sending so many events back to
| the main UI thread its bogging it down.
|
| What is the best practice for high throughput & chatty asynchronous
| process?
|
| I'm using "System.ComponentModel.AsyncOperation.Post()" to raise the
| events on the UI thread. So I am thinking to not use AsyncOperation and
| post the event on the asynchronous thread and then switch to the UI
| thread only to update the user controls. Not sure but I think I will
| have the same problem.
|
| Thanks for the reply
| sprayer
| MCAD.NET
|
|
| *** Sent via Developersdex http://www.developersdex.com ***
Jun 8 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Raghul | last post by:
hi I am working in making a jabber client.I made upto chatting with each other.Any number of people can be simultaneously chat.My problem is that If I am initiated to talk then the application...
2
by: Jonathan | last post by:
Running IIS 5.0. Running both .NET and ASP pages. Every several weeks all the ASP pages stop responding. Nothing is displayed. No events show up in event logs showing that the server is having...
0
by: Michael Bourgon | last post by:
I've been having the same problem for 2 weeks now. If anyone has any ideas, I'd love to hear them. We are using both SQL and Windows Authentication. I was running a Profiler Trace at the time,...
13
by: long5120 | last post by:
I am trying to use webpage with javascript to check if a web server is responding. I was thinking of using 2 frames. Frame1 will have the site, and the Frame2 will be a status bar (not really...
2
by: Nils Hedström | last post by:
Today my stateserver (running at the same computer at the web-server) suddenly stopped responding (after 10 days working perfectly). I did not see any entry in the eventlog indicating that the...
4
by: VB Programmer | last post by:
When I run my ASP.NET 2.0 web app on my dev machine it works perfect. When I precomile it to my web deployment project and then copy the debug files to my web server I get this problem when trying...
1
by: Ron | last post by:
Hi, I had a stored procedure on SQL 2000 server to run calculation with large amount of data. When I called this stored procedure via System.Data.SqlClient.SqlCommand on production, i got error...
0
by: hellboss | last post by:
Hi ! Im working with asp.net, I have a Update Panel(Ajax tool) where two text boxes are placed and in Text box 1, i enter the Email and the max length for the field is set to 75. and another text...
18
by: rdahlstrom | last post by:
Does anyone know how to determine the window status (Running or Not Responding)? I've tried various methods with no success... This would be on a variety of Windows systems, but all at least XP,...
7
by: mills.toby | last post by:
We have a Windows 2003 Server, serving an asp.net (2.0) website. Recently the website stopped responding. When trying to access the website, no response is received at all. This includes when...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.