473,327 Members | 2,074 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,327 software developers and data experts.

c# Gui Freeze when waiting for Data

Lam
hi
I am writing a C# windows program which will get datatable from database through ODBC connection
then I show the the datatable on DataGridView.
The problem is that before the datatable get returned, the GUI freezes. I can't move it
On the program, I have different queries to get the different data back, some of them
get back withthin few seonds, some of them takes minutes to get the databack.is there anyway that
I can still be using the GUI (clicking on other control, enter some text. etc) while waiting for the data to show up?

Thanks
Mar 30 '06 #1
5 7133
You are invoking on the UI Thread. Invoke the database call on a worker
thread or a thread pool thread and then update the UI the moment you
get back the data from the database.

Mar 30 '06 #2
Shift the data access into a different thread.

If you're using .NET 2.0, see the BackgroundWorker class.
"Lam" <ja**********@hotmail.com> wrote in message news:eb**************@TK2MSFTNGP09.phx.gbl...
hi
I am writing a C# windows program which will get datatable from database through ODBC connection
then I show the the datatable on DataGridView.
The problem is that before the datatable get returned, the GUI freezes. I can't move it
On the program, I have different queries to get the different data back, some of them
get back withthin few seonds, some of them takes minutes to get the databack.is there anyway that
I can still be using the GUI (clicking on other control, enter some text. etc) while waiting for the data to show up?

Thanks
Mar 30 '06 #3
Lam

I have a class, (DBManager.cs) to call to access the database , then it returns the datatable to calling class
then the calling class bind the datatable to the DataGridView to show

you mean I have to create the thread to call DBManager?
can you show me a example?
Thanks a lot

"Brendan Green" <bg****@simtap.com.au> wrote in message news:uC**************@TK2MSFTNGP14.phx.gbl...
Shift the data access into a different thread.

If you're using .NET 2.0, see the BackgroundWorker class.
"Lam" <ja**********@hotmail.com> wrote in message news:eb**************@TK2MSFTNGP09.phx.gbl...
hi
I am writing a C# windows program which will get datatable from database through ODBC connection
then I show the the datatable on DataGridView.
The problem is that before the datatable get returned, the GUI freezes. I can't move it
On the program, I have different queries to get the different data back, some of them
get back withthin few seonds, some of them takes minutes to get the databack.is there anyway that
I can still be using the GUI (clicking on other control, enter some text. etc) while waiting for the data to show up?

Thanks
Mar 30 '06 #4
Lam
it sounds the solution for the problem
so should I create the thread pool or worker thread on seperate (individual class)?
or can I do it in the same class that create the form?
thanks

"Naveen" <na*********************@gmail.com> wrote in message news:11**********************@u72g2000cwu.googlegr oups.com...
You are invoking on the UI Thread. Invoke the database call on a worker
thread or a thread pool thread and then update the UI the moment you
get back the data from the database.

Mar 30 '06 #5
You should read up on delegates, BeginInvoke, EndInvoke, callback
delegates, and the like. Here is an article to get you started. The
code in the article is Visual Basic, but it's easy enough to understand
and translate the ideas into C#:

http://msdn.microsoft.com/msdnmag/is...asicInstincts/

Mar 30 '06 #6

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

Similar topics

11
by: Matt Kruse | last post by:
This is a common requirement - "freeze panes" in a table, so that some header rows and some columns on the left are frozen while the body content scrolls. This makes large tables more usable on...
1
by: Dan | last post by:
I have created an Excel worksheet using automation from a VB.NET application. The worksheet is never made visible by the VB program. It is created and filled with data from a database and then...
2
by: aww91 | last post by:
Company is planning a Sybase to UDB migration that is projected to take 1 year. During that long period of time any Code Freeze put into place would impact our users (we normally release code...
11
by: Timothy Shih | last post by:
Hi, I am having a freezing issue with my application. My application serves several remotable objects, all of which must be initialized before their use. Furthermore, some of them depend on each...
6
by: Agnes | last post by:
I understand it is impossible, but still curious to know "Can I freeze several column in the datagrid, the user can only scroll the first 3 columns (not verical), for the rest of the coulumn, it is...
4
by: Roger Withnell | last post by:
I would like to freeze column and row headings on a webpage, simulating freeze panes as in an Excel spreadsheet. Don't seem to be able to do it with Frames. Is there a way with Javascript...
1
by: guy.flowers | last post by:
Hi Have a problem, Ill give some history to the problem and add a little example code to start with to see if anybody can help or if I am correct in what the problem is. I have been looking...
1
by: jmalone | last post by:
I have a python script that I need to freeze on AIX 5.1 (customer has AIX and does not want to install Python). The python script is pretty simple (the only things it imports are sys and socket)....
4
by: ToxSox | last post by:
Hello. This is my first post here and i have a big problem with my script! One page (child.htm), was delivered not by me and i can't change it. This page calls a methode in a object of my page....
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.