I hope you can help me on this. I need to implement a loading window or loading bar while I'm running a query to a MSSQL database using VB.NET. My goal is to avoid my program to hang while the script is still querying the database server.
Asked
Active
Viewed 879 times
0
-
Hi DeanOC, I'm using a winforms. My goal is just to avoid my program from hanging while waiting for results from my query. – helios99 May 07 '15 at 09:13
-
Sound like you want to use the async/await functionality. You make an asynchronous call to the db, show a "please wait" dialog, and when the call returns, you dismiss the dialog. – DeanOC May 07 '15 at 09:30
-
Check any tutorial on Tasks and ADO.NET asynchronous programming, eg: MSDN's [Asynchronous Programming](https://msdn.microsoft.com/en-us/library/hh211418%28v=vs.110%29.aspx) – Panagiotis Kanavos May 07 '15 at 09:32
-
Hi DeanOC and Panagiotis, that is what I'm looking at now. Do you have samples with actual sql query? – helios99 May 07 '15 at 09:37
-
The actual task should be irrelevant to the async process. You should be able to take your existing synchronous task and wrap it in an async call. There are plenty of examples out there. – DeanOC May 07 '15 at 09:48
2 Answers
0
try creating a panel that is transparent with GIF loading image that shows up when loading a code and then hides/destroyed when its complete.
Private Sub EventName()
panel1.Show()
-- ToDo: Do Something
panel1.Hide()
End Sub

xxxAcuGeekxxx
- 133
- 11
0
All that you need to do is have the long operation running on a background thread updating a progress bar on the main thread. There are plenty of examples online, here is a popular answer of mine:

Community
- 1
- 1

Jeremy Thompson
- 61,933
- 36
- 195
- 321
-
You mean running the MSSQL-Query in a background thread. The Progress bar can/must be drawn in the GUI-Thread – C0d1ngJammer May 08 '15 at 07:19
-
-
You do realize that the Async method has the same outcome as a background worker? – Jeremy Thompson May 10 '15 at 00:26