W
Wayne Bradney
Hi,
I have an application where the login to the server could take 30-40
seconds. I have a main form with a "Login" button on it and a handler:
private void btnLogin_Click(object sender, System.EventArgs e) {
Cursor.Current = Cursors.WaitCursor;
log.Debug("About to open session");
session = Session.Open("username", "password", "instance", "server");
log.Debug("Opened session");
btnAdapters.Enabled = true;
btnCache.Enabled = true;
Cursor.Current = Cursors.Default;
}
The Session class encapsulates the login/logout operations (which are
interop calls to COM code). What's happening is that the Cursor stays
as an hourglass for about 10 seconds and then changes back to an arrow
- while the login is still executing. Session.Open doesn't return; the
other buttons stay disabled and the form doesn't respond to mouse
clicks immediately, but 20-30 seconds later (when the login operation
completes), the other buttons are enabled and all of the mouse clicks
I performed while the form appeared "dead" suddenly take effect (forms
start popping up).
How do I set the hourglass and kill the mouse for the full duration of
the opration, like I could with VB6? If I replace the login code with
a line that puts the thread to sleep for 40 seconds, I don't see the
same behaviour: the hourglass stays around for the full 40 seconds and
the form is truly dead to mouse operations - which is just what I
want.
I have an application where the login to the server could take 30-40
seconds. I have a main form with a "Login" button on it and a handler:
private void btnLogin_Click(object sender, System.EventArgs e) {
Cursor.Current = Cursors.WaitCursor;
log.Debug("About to open session");
session = Session.Open("username", "password", "instance", "server");
log.Debug("Opened session");
btnAdapters.Enabled = true;
btnCache.Enabled = true;
Cursor.Current = Cursors.Default;
}
The Session class encapsulates the login/logout operations (which are
interop calls to COM code). What's happening is that the Cursor stays
as an hourglass for about 10 seconds and then changes back to an arrow
- while the login is still executing. Session.Open doesn't return; the
other buttons stay disabled and the form doesn't respond to mouse
clicks immediately, but 20-30 seconds later (when the login operation
completes), the other buttons are enabled and all of the mouse clicks
I performed while the form appeared "dead" suddenly take effect (forms
start popping up).
How do I set the hourglass and kill the mouse for the full duration of
the opration, like I could with VB6? If I replace the login code with
a line that puts the thread to sleep for 40 seconds, I don't see the
same behaviour: the hourglass stays around for the full 40 seconds and
the form is truly dead to mouse operations - which is just what I
want.