ways to provide a synchronous response from an asynchronous task - Page 2-VBForums
Page 2 of 2 FirstFirst 12
Results 41 to 48 of 48

Thread: ways to provide a synchronous response from an asynchronous task

  1. #41
    Fanatic Member
    Join Date
    Jun 2012
    Posts
    608

    Re: ways to provide a synchronous response from an asynchronous task

    Quote Originally Posted by Eduardo- View Post
    The asynchronous component usually notifies that it finished with an event, but there could be also a property that one can check to see whether it finished or not, for example Object.StillExecuting
    I did not read the full thread. But my generic Multithreader comes into my mind. http://www.vbforums.com/showthread.p...%29&highlight=
    It is a class object which is event driven. When a new thread is started a asynchronous event is fired and within that event a synchronous callback to the original thread can be started. The original thread will be suspended until that callback is finished and it returns back to the asynchronous event and when that ends the new thread is terminated.
    You may create as many threads as necessary. There is a demo project included which shows how to use it.

    The downside is that it is a separate Ax-DLL. However, there is a Registration-Free (Side-by-side) solution available. (via manifest)
    Last edited by Krool; Apr 19th, 2017 at 02:03 PM.

  2. #42

    Thread Starter
    Addicted Member
    Join Date
    Feb 2017
    Posts
    192

    Re: ways to provide a synchronous response from an asynchronous task

    Thanks Krool for sharing that project.
    At some point I'll have to venture into the world of threading. I still didn't have to do a very intensive and long processing task, but when I have, I'll need it.

    I see threading as a way to take advantage of the new processor architectures (of having several cores). Aside from that, I don't know if there are other advantages.

    About the other subject of not locking the IDE when doing a long task, it's logically impossible to avoid reentrancy, unless disabling the UI (or the functions of the UI that can cause reentrancy for the particular case).
    I don't think that threading could change that, since as I see it, it's logically impossible: if the UI is not locked or disabled, then the user can fire something that can cause reentrancy.

    The only things to do are whether to disable the UI or to handle the reentrancy.

  3. #43
    Fanatic Member
    Join Date
    Jun 2012
    Posts
    608

    Re: ways to provide a synchronous response from an asynchronous task

    Quote Originally Posted by Eduardo- View Post
    Thanks Krool for sharing that project.
    At some point I'll have to venture into the world of threading. I still didn't have to do a very intensive and long processing task, but when I have, I'll need it.

    I see threading as a way to take advantage of the new processor architectures (of having several cores). Aside from that, I don't know if there are other advantages.

    About the other subject of not locking the IDE when doing a long task, it's logically impossible to avoid reentrancy, unless disabling the UI (or the functions of the UI that can cause reentrancy for the particular case).
    I don't think that threading could change that, since as I see it, it's logically impossible: if the UI is not locked or disabled, then the user can fire something that can cause reentrancy.

    The only things to do are whether to disable the UI or to handle the reentrancy.
    When the thread is started, you can check in your UI if the thread is still active. Thus you can avoid the reentrancy.
    In my demo project the form cannot be closed until the asynchronous thread is finished. But of course it can be a check to not start a new thread.

  4. #44

    Thread Starter
    Addicted Member
    Join Date
    Feb 2017
    Posts
    192

    Re: ways to provide a synchronous response from an asynchronous task

    Quote Originally Posted by Krool View Post
    When the thread is started, you can check in your UI if the thread is still active. Thus you can avoid the reentrancy.
    In my demo project the form cannot be closed until the asynchronous thread is finished. But of course it can be a check to not start a new thread.
    I've run your demo project.
    If I start the task, then show a form, then leave it open until after the task ends, I get a crash.

  5. #45
    Fanatic Member
    Join Date
    Jun 2012
    Posts
    608

    Re: ways to provide a synchronous response from an asynchronous task

    Quote Originally Posted by Eduardo- View Post
    I've run your demo project.
    If I start the task, then show a form, then leave it open until after the task ends, I get a crash.
    Yes its unstable in the IDE. But compiled it is stable.
    That point is mentioned in the topic.

    Reasion is simple. The IDE is only in the main thread. Even ActiveX EXE objects are running in IDE in the main thread. So no show-stopper.
    Last edited by Krool; Apr 19th, 2017 at 05:02 PM.

  6. #46

    Thread Starter
    Addicted Member
    Join Date
    Feb 2017
    Posts
    192

    Re: ways to provide a synchronous response from an asynchronous task

    Quote Originally Posted by krool View Post
    yes its unstable in the ide. But compiled it is stable.
    That point is mentioned in the topic.

    Reasion is simple. The ide is only in the main thread. Even activex exe objects are running in ide in the main thread. So no show-stopper.
    ok..

  7. #47
    Junior Member
    Join Date
    Feb 2017
    Posts
    28

    Re: ways to provide a synchronous response from an asynchronous task

    Stumbled across this -- NOT VB6 -- but may be of interest as appears to be what your after.

    http://stackoverflow.com/questions/1...od-to-complete

  8. #48

    Thread Starter
    Addicted Member
    Join Date
    Feb 2017
    Posts
    192

    Re: ways to provide a synchronous response from an asynchronous task

    Quote Originally Posted by vb6forever View Post
    Stumbled across this -- NOT VB6 -- but may be of interest as appears to be what your after.

    http://stackoverflow.com/questions/1...od-to-complete
    Thanks, I'll take a look.

Page 2 of 2 FirstFirst 12

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.