[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 234
  • Last Modified:

display form while awaing for another command to run

i have an sqlcommand that i run to populate  a dgv on my form that can take upto 10 min.

what i would like to do is when the button is pressed change the cursor to the hourglass, bringup a form i have created that will have an animated gif on it.  then when the query finishes the form dissappear and the cursor return to normal again.

i have seen somethin about threading, but have not found an example that i have understood.


0
Marcusw
Asked:
Marcusw
  • 6
  • 4
1 Solution
 
wsh2Commented:
For the hourglass..
   me.Cursor=Cursors.WaitCursor

For calling the other Form..

   MyOtherForm.Show()

-------------------------------------------------------------------------------------------
In MyOtherForm, place a public boolean variable called booShutDown and periodically test it for True. If True, do a Me.Close. In your calling Form, when your sqlCommand is done, set MyOtherForm.booShutDown = True.
-------------------------------------------------------------------------------------------
Waiting 10 minutes for ANY command to complete is an eternity. What type of query is this?
0
 
MarcuswAuthor Commented:
it is a sql query that brings back various stats based on criteria entered into the form.

sometimes it can only be a couple of seconds,

do i have to use a timer to check every say 1 second.  if so will this hinder the performance?
0
 
wsh2Commented:
A timer every second should be fine.. <smile>.

Remember, your computer is not doing much. It is displaying a graphic and waiting (for data). There are resources available for the timer.

For those 10 minute queries, you may in the future want to take a look at SQL Server's OLAP Reporting Services. Reporting Services, allows you to build cubes of data for rapid analytical access. It is rather involved, but just may be the type of tool your organization might need.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
wsh2Commented:
Oops.. my apologies.. that is Analysis Services.. not Reporting.. <sheepish grin>.
0
 
MarcuswAuthor Commented:
thanks for the info, i will have a look at that when i get chance.

i have tried the timer idea, but the problem seems to be as soon as the command
splashscreen1.showdialog runs, the rest of the code stops until that form is closed

what now?
0
 
MarcuswAuthor Commented:
i've just been looking around, do i have to use a command doEvents ?  and if so how?
0
 
wsh2Commented:
ShowDialog WILL stop your application. Remove the Dialog part. (i.e. Show())

If you want to stop any input on the calling Form.. do a MyCallingForm.Enabled = False.. set Enabled back to True when your SQL statement is done.
--------------------------------------------------------------------------
Application.DoEvents

Is the .Net counterpart.
0
 
wsh2Commented:
Or.....
Use MyCallingForm.Visible = False if you want to hide the calling form.. set Visible back to True when you aready.

.Enabled = False.. if you want to keep the calling form visible but have no activity.
.Visible = False.. if you want to hide the calling form

Both have the same effect.. no user input allowed.. on the calling form. Your pop-up form will still work.


0
 
MarcuswAuthor Commented:
thanks that bit now works but for some reason it is not seeing my bool variable.  the sql runs and finishes but the splash screen does not close

in my main form i have
Public Class MainForm
Public bool as boolean

then in my button click event

    Dim splash As New SplashScreen1
        bool = False
        splash.Show()
        maincount(fullsql) '"select count(*) TOTAL,count(*) TEL,count(*) EMAIL from TEster..tblclasscodes")
        bool = True

in my splash form i have

    Private Sub SplashScreen1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Timer1.Interval = 1000
        Timer1.Start()
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

        If bool = True Then
            Timer1.Stop()
            Me.Close()
        End If
    End Sub

0
 
wsh2Commented:
If MainForm.bool = True Then
    Timer1.Stop()
    Me.Close()
End If



0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now