Results 1 to 6 of 6

Thread: [RESOLVED] [2005] Program Freezing when PC is Locked

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2003
    Posts
    406

    Resolved [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?

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2003
    Posts
    406

    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.

  3. #3

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2003
    Posts
    406

    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.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2003
    Posts
    406

    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!

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Program Freezing when PC is Locked

    Quote 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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width