|
-
Dec 17th, 2008, 04:16 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] [2005] Program Freezing when PC is Locked
Hello!
I have a weird problem.
I have a program that freezes up when the PC is locked (CTRL ALT DEL).
When it is in the VB .NET environment, it does not do this, only when running the exe by itself.
Anyone ever seen this before?
-
Dec 17th, 2008, 04:59 PM
#2
Thread Starter
Hyperactive Member
Re: [2005] Program Freezing when PC is Locked
OK, i have narrowed it down to this code causing it:
Me.TopMost = true
then some code
Me.TopMost = False
Any idea why that would cause it to freeze up on the CTRL ALT DELETE?
The reaon i was using it is to push the form to the top when it was done processing something. in case the user was working on something else.
-
Dec 17th, 2008, 05:01 PM
#3
Re: [2005] Program Freezing when PC is Locked
I doubt a program would be able to become TopMost when the PC is locked...? That would probably be your problem.
-
Dec 17th, 2008, 05:06 PM
#4
Thread Starter
Hyperactive Member
Re: [2005] Program Freezing when PC is Locked
But the code put it into topmost = true, then to topmost = false.
After the process is done running, I hit CTRL ALT DEL.
Its tricky.
-
Dec 17th, 2008, 06:24 PM
#5
Thread Starter
Hyperactive Member
Re: [2005] Program Freezing when PC is Locked
Narrowed it down even more. The TopMost that was causing it was in a procedure thata was called in a background workers dowork sub.
Still not sure why it wasn't causing an error, but found it. Whew!
-
Dec 17th, 2008, 09:56 PM
#6
Re: [2005] Program Freezing when PC is Locked
 Originally Posted by jeffcravener
Narrowed it down even more. The TopMost that was causing it was in a procedure thata was called in a background workers dowork sub.
Still not sure why it wasn't causing an error, but found it. Whew!
You are not supposed to access control members from any thread other than the one on which they were created. Sometimes it can work but many times you get unexpected results and this is a case in point. You need to either:
1. set the TopMost property of the form only before calling RunWorkerAsync, in the ProgressChanged event handler or in the RunWorkerCompleted event handler; or
2. use delegation to marshal a call to the UI thread.
The links in the Multithreading section of my signature may be helpful to you.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|