Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9205577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:58:55+00:00 2026-06-17T23:58:55+00:00

I have been trying to get a function to work asynchronously with a GUI

  • 0

I have been trying to get a function to work asynchronously with a GUI window, and having very limited success.

The code below is my function, XXX, with a delegate and Callback – to allow stopping the GUI thread, without getting an error.

It works though – if it is a Sub, not a function, and if it doesn’t have any arguments.

I don’t know how to change it so I can check its return value… I have found a little help in some examples, http://msdn.microsoft.com/en-us/library/system.iasyncresult.asyncstate.aspx – but they print the return value in the callback, and I can’t see how to get it in the caller.

I can’t find any way to use arguments in my function.

Private Function XXX_Callback(ByVal ia As IAsyncResult) 
    Dim d As XXXDelegate = CType(CType(ia, Runtime.Remoting.Messaging.AsyncResult).AsyncDelegate, XXXDelegate)
    d.EndInvoke(ia)

    Dim result As AsyncResult = CType(ia, AsyncResult)
    Dim caller As XXXDelegate = CType(result.AsyncDelegate, XXXDelegate)
    Dim returnValue As Boolean = caller.EndInvoke(ia)

    XXX_Finish()   ' needs the "vvv argument, I don't know how to get it
    ' The returnValue is here but I don't know how to send it to the caller
End Function

'Private Function XXX_Finish(ByVal vvv as Boolean) As Boolean
' this probably needs to return something, I don't know what/ how to get it
Private Function XXX_Finish() As Boolean
    ' something 
    myGui.Finish()            
End Function

' Private Delegate Function XXXDelegate(ByVal vvv As Integer) As Boolean
' Public Function XXX(ByVal vvv As Integer) As Boolean    ' This is what I would like
Private Delegate Sub XXXDelegate()
Public Sub XXX() 
    '
    myGui.Update()
    '
End Sub

Public Sub Caller()
    '
    myGui = New SomeGui()
    myGui.Begin()
    Dim t As New XXXDelegate(AddressOf XXX)
    t.BeginInvoke(AddressOf XXX_Callback, Nothing)
    ' more code, another call
End Sub

Private myGui As SomeGui

Please, could someone help me get this into a better shape, or get some examples that will help ? With the ones I have found in the past two days, I have reached a dead end…

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T23:58:56+00:00Added an answer on June 17, 2026 at 11:58 pm

    After searching through lots of posts on the web, and reading a couple of books, I have found the best resource, with examples for each case that one might encounter:

    http://support.microsoft.com/kb/315582

    The answers to this particular question are in the above link, “Sample 2: Calling A Method Asynchronously by Using the EndInvoke() Call Pattern” and “Sample 5: Executing a Callback When an Asynchronous Method Completes.”

    The best thing about it though is the simple and organized fashion in which the options to use Invoke, EndInvoke, Callback are explained.

    One thing to note: for my question above, the essential breakthrough was when I read the words “BeginInvoke() returns immediately and does not wait for the asynchronous call to complete.“

    So… trying to call another method, after it, was the wrong approach.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to get this code to work for a while now
I have been trying to get Twitter Bootstrap btn-group with dropdown to work for
I have been trying to get nServiceBus to work with Ninject 2.0 as the
I have been trying to get the following code working. It's a progress bar
I have been trying to get autocomplete to work using jquery. jsFiddle of example
I have been trying to get bootstrap popovers to work within a Wordpress loop
Here is a hard one I have been trying to get it work. It
I have been trying to get my menu to work, however it seems that
well I have been trying to get Nivo Slider to work almost all day.
for a long while, i have been trying to get a piece of code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.