Results 1 to 8 of 8

Thread: Disable handler until code complete.

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    816

    Resolved Disable handler until code complete.

    I don't know how to put a title to this.

    I made a plugin a for a program that has a Datagridview. Lengthy code runs when selecting cells.

    When I click between cells a little faster than the program likes it crashes the program it is plugged into.

    I created an invisible modal form to cover the controls and prevent clicks while it is executing but it doesn't seem to work.

    Is there anything anyone can suggest? Is the code being broken somehow by a second click or is it added to a command stack?
    Last edited by sgrya1; Dec 6th, 2021 at 10:48 AM.

  2. #2
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,543

    Re: Disable handler until code complete.

    w/o seeing the code, it's hard to tell. It could be anything. To solve it, you could try removing the handler of the click event, or you could try simply disabling the control so that the user can't then click on it.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    816

    Re: Disable handler until code complete.

    Disabling the control.

    So I'm 100% sure I've tried that before but it seems to be working fine now. Can't think of what the problem was and why I switched to such a messy alternative. And one that doesn't even appear to work.
    Thank you.

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    816

    Re: Disable handler until code complete.

    I've just worked out why I thought I had tried this.

    My problem is now with combobox .enter or .click.
    Temporarily disabling the control while code executes boots me out of it, so I can't go into edit mode.
    Is there an alternative I could use for this one?

    And is there a call stack? One that should theoretically allow code to complete instead of aborting it?

    Edit: I shouldn't be able to Enter the cell twice in rapid succession.
    Maybe I need some time to think about why this one has also been causing problems.
    Last edited by sgrya1; Dec 6th, 2021 at 11:16 AM.

  5. #5
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,047

    Re: Disable handler until code complete.

    What you are wanting to happen is normally the default behavior, so something is a bit odd.

    If you trigger some event handler, that will normally be ALL the UI is capable of doing. A second action might (or might not) trigger a subsequent event, but that subsequent event won't interrupt running code. Those events just post messages to the message queue, and the UI won't process messages off the queue until it is free to do so. A control won't even know that you clicked on it if the UI is too busy to process the mouse click message. That's why long running processes need to be moved to a background thread so that the UI can remain free to respond to user actions.

    What you are describing is that one user action can interrupt a process. If that process isn't on a different thread, that shouldn't even be possible. If the process IS on a different thread, then the problem you are running into has to do with thread safety, which is a different matter.

    So, something isn't making sense.
    My usual boring signature: Nothing

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    816

    Re: Disable handler until code complete.

    I wonder if has something to do with the program I am plugging into (AutoCAD).
    I'm trying to think of a way to see if it is actually aborting code a double click.

  7. #7
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,543

    Re: Disable handler until code complete.

    As much as I hate to sound like an echo chamber...
    Quote Originally Posted by techgnome View Post
    w/o seeing the code, it's hard to tell. It could be anything.
    Maybe if you post the - relevant - code you're using, we can help... otherwise we're all just shooting in the dark here.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  8. #8
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,047

    Re: Disable handler until code complete.

    And that's fun, by the way, but you tend to hit things you don't mean to hit.
    My usual boring signature: Nothing

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