Hi ,
I would like a progress bar to be displayed while running an sql query. the progress bar doesn't have to move according to the query pace - I just want it to move back and forth while the query is executing , and to disappear when the query is completed.
My problem is that the progress bar does not appear when the query is running (I'm using the data adapter fill method in order to run my queries). What can I do ?
Thanks in advance.
Oct 19 '07
12 35087
am doing the same thing but am stuck with the threads join?? will you help about it?
You don't really need to join back up with the main thread, nor even wait for the spawned thread to finish. First, you'll need these methods: - private delegate void SetControlPropertyThreadSafeDelegate(Control control, string propertyName, object propertyValue);
-
public static void SetControlPropertyThreadSafe(Control control, string propertyName, object propertyValue)
-
{
-
if (control.InvokeRequired)
-
{
-
control.Invoke(new SetControlPropertyThreadSafeDelegate(SetControlPropertyThreadSafe),
-
new object[] { control, propertyName, propertyValue });
-
}
-
else
-
{
-
control.GetType().InvokeMember(propertyName, BindingFlags.SetProperty, null, control, new object[] { propertyValue });
-
}
-
}
-
private void StartProgressBar(ProgressBar pb)
-
{
-
SetControlPropertyThreadSafe(pb, "Visible", true);
-
SetControlPropertyThreadSafe(pb, "Style", ProgressBarStyle.Marquee);
-
SetControlPropertyThreadSafe(pb, "MarqueeAnimationSpeed", 100);
-
}
-
private void StopProgressBar(ProgressBar pb)
-
{
-
SetControlPropertyThreadSafe(pb, "Style", ProgressBarStyle.Blocks);
-
SetControlPropertyThreadSafe(pb, "MarqueeAnimationSpeed", 0);
-
SetControlPropertyThreadSafe(pb, "Visible", false);
-
}
Using this, you can set the progress bar to either be running or stopped from within your thread. Use these two calls within the threaded method to start/stop:
StartProgressBa r(ProgressBar);
StopProgressBar (ProgressBar);
Generally, between those two, I do some processing, and then call Invoke(new MethodInvoker(< Method>)) to save the results of the thread to the main form. Essentially, it works by a) starting the thread, b) gathering data/perform some sort of task, c) invoking the method which uses the data that you've saved from your thread (which is threadsafe, due to Invoke()), d) finishing it up by stopping the progress bar
Hope this helps
Try using
to free your UI while you run those threads.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: dixie |
last post by:
I have a command to open the Access Options dialogue from code:
DoCmd.RunCommand acCmdOptions
It also opens the Database Window behind it. Is it possible to open the
Options without having the database window open as well?
dixie
|
by: needin4mation |
last post by:
Please consider:
foreach (ListViewItem item in listViewFiles.Items)
{
// Display the ProgressBar control.
pBar1.Visible = true;
// Set Minimum to 1 to represent the first file being copied.
pBar1.Minimum = 1;
// Set Maximum to the total number of files to copy.
pBar1.Maximum = 4; //filenames.Length;
|
by: Mehr H |
last post by:
I've been trying to figure out how i can embed a Windows.Forms.ProgressBar
in my webform (aspx) file.
I have tried putting a Windows.Forms.ProgressBar as public on a regular
winform designer form (form called ProgressForm) and the built the dll.
Then I reference this new assembly from within my asp.net applicaiton and
tried to access Windows.Forms.ProgressBar from within the ProgressForm but
apparently it doesn't work.
Because it won't...
|
by: Mitchell Vincent |
last post by:
In other programming languages I've been able to easily change the style
of a progress bar between smooth and blocked. I find that is either
really hidden or impossible in .NET. Am I missing something?
I'm shocked that .NET doesn't have a style property for the progressbar
control!
--
- Mitchell Vincent
- kBilling - An easy and affordable billing solution
|
by: nobody |
last post by:
Hi
I'm currently developing a Windows application. At the start of the
application I load several tables into datatables in a dataset. I also use
a progressbar to show the user how much percent of the total is already
loaded. But I do this in a dirty way: I increment the progressbar with the
same number after each table, but not all tables contain the same amount of
data. I solved this with starting an other thread to increment the...
| |
by: =?Utf-8?B?QWFyb24=?= |
last post by:
Since some controls such as the DataGridView take a long time to update
themselves when performing certain tasks, I have added a StatusStrip with a
ProgressBar on it. While I am updating the controls on the form, I want the
ProgressBar to scroll in marquee mode. However, I cannot seem to get this to
work.
I set the StatusStripLabel to the text I want such as "Updating data..." and
then set the ProgressBar's Style property to Marquee...
|
by: sivamoorthy |
last post by:
how to use a progressbar in a one cpp file but defined in another header file.
the function in which i am using is a static member function. how to use the progressbar inside the function
code:
file name : flash.cpp
void CFlasher::OnStartDownload (void *pDublicate)
{
bValueRet = DeviceIoControl (hHandle, \
(DWORD) IOCTL_SCUSBDFU_DETACH, NULL, \
|
by: JB |
last post by:
Hi All,
I have a Windows Form application that shows a "please wait" form
while I query a database for various information.
I display my form using Show, then run my DB query, then Close the
form at the end.
To make it look even nicer I placed a marquee style Progress Bar on my
form.
It works exactly the same way, but the marquee style progress bar
|
by: hsegoy1979 |
last post by:
dear all
iam new to sql server. I have a query. I want to display records in a new line.
Iam using char(13) but it won't work.
The table record contains only one field Name
select * from record
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |