473,378 Members | 1,378 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,378 software developers and data experts.

Using threading to call sql script

VMI
How can I use threading in my Windows Form to call a sql script that takes a
few seconds to run? When I click on a button, I'd like to call the SP,
display in my Form message a "Please wait" message, and then when the script
is done, fill the grids with this data.
I've read deveral articles on multithreading, but I really haven't found how
to "join" it to my gui thread once this new thread finishes.

Any help is appreciated. I'm using VS2005.

Thanks.


May 3 '07 #1
3 1618
VMI <vo******@yahoo.comwrote:
How can I use threading in my Windows Form to call a sql script that takes a
few seconds to run? When I click on a button, I'd like to call the SP,
display in my Form message a "Please wait" message, and then when the script
is done, fill the grids with this data.
I've read deveral articles on multithreading, but I really haven't found how
to "join" it to my gui thread once this new thread finishes.
I don't think you'll need Thread.Join here, but you'll almost certainly
want Control.Invoke or Control.BeginInvoke to "get back" onto the UI
thread so that you can update the UI from the right thread.

See http://pobox.com/~skeet/csharp/threads/winforms.shtml

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
May 3 '07 #2
There are various ways of accomplishing this task. Simple way is to
create a method that executes SQL task.

On your GUI thread, create a new thread and pass the above function as
ThreadStart. Start the new created thread. On your GUI thread you can
check the status of newly created thread on a timely fashion (for this
you can use a timer control). You can use the IsAlive property of thread.
If IsAlive returns false, that means thread have completed the execution
of method and result is ready to be displayed.

--
Tariq Karim | Capgemini | El-Segundo
Senior Consultant | Telecom Media and Entertainment
Mobile: +01 832-433-6055 | www.capgemini.com
Join the Collaborative Business Experience

VMI wrote:
How can I use threading in my Windows Form to call a sql script that takes a
few seconds to run? When I click on a button, I'd like to call the SP,
display in my Form message a "Please wait" message, and then when the script
is done, fill the grids with this data.
I've read deveral articles on multithreading, but I really haven't found how
to "join" it to my gui thread once this new thread finishes.

Any help is appreciated. I'm using VS2005.

Thanks.

May 4 '07 #3
Take a look at the BackgroundWorkerClass. It might be what you're looking
for.

"VMI" <vo******@yahoo.comwrote in message
news:ui**************@TK2MSFTNGP05.phx.gbl...
How can I use threading in my Windows Form to call a sql script that takes
a
few seconds to run? When I click on a button, I'd like to call the SP,
display in my Form message a "Please wait" message, and then when the
script
is done, fill the grids with this data.
I've read deveral articles on multithreading, but I really haven't found
how
to "join" it to my gui thread once this new thread finishes.

Any help is appreciated. I'm using VS2005.

Thanks.


May 4 '07 #4

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

Similar topics

2
by: Egor Bolonev | last post by:
hi all my program terminates with error i dont know why it tells 'TypeError: run() takes exactly 1 argument (10 given)' =program==================== import os, os.path, threading, sys def...
5
by: Francois De Serres | last post by:
Hiho, could somebody please enlighten me about the mechanics of C callbacks to Python? My domain is more specifically callbacks from the win32 API, but I'm not sure that's where the problem...
3
by: Alex | last post by:
I'm having a problem porting an ASP solution to ASPX. In the ASP solution I'm accessing a DCOM server, create sub DCOM objects and call functions from VB script on the ASP pages. The DCOM object...
4
by: rh0dium | last post by:
Hi all, I have a problem with putting a job in the background. Here is my (ugly) script which I am having problems getting to background. There are threads about doing python script.py & ...
2
by: Chen Houwu | last post by:
------------------sample code begin------------------------- import threading import wmi def run(*args): c = wmi.WMI () memory=c.Win32_LogicalMemoryConfiguration() info='Total Virtual...
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)....
6
by: =?Utf-8?B?U2hhd24gU2VzbmE=?= | last post by:
Greetings! I was researching AJAX to provide a solution to displaying status messages while a long process executed. I found several examples online and was able to use their code to get a quick...
5
by: George Maicovschi | last post by:
As multi-threading is not built in PHP I've been using a hack letting the Apache server handle the multi-threading issues, but I'm really curious of other approaches to this issue. If anyone has...
1
by: ~levon | last post by:
Hello group, in following example, a signal handler is registered and a thread started. if I call self.doSomethin() directly the code works as I would expect. as i send a SIGINT shutdown is...
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...
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.