Solved

Calling a subroutine and continuing the code after the subroutine without waiting for the subroutine to finish

Posted on 2007-11-13
3
340 Views
Last Modified: 2013-11-26
Hello,

I have a sub to be called from sub main. But I want this call of the subroutine, not to wait for the subroutine to finish execution, but rather it should do its job aside and the sub main should continue the code after it. Plus this should be in iterative way, not only calling the subroutine once.

For example:

Sub Main()
        'Procedure level variables
        Dim x
        Dim y
        .........

                    For x=0 to 10

                            <code>.....
                            Extract(y)
                            <code2>.....

                    Next
end sub

sub Extract (byval value)
          <code 3>
end sub

So once Extract(y) is called, code 3 should execute on the side, and at the same time code 2 should continue and do its work even go to the next iterate.
0
Comment
Question by:naafii_dxb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 14

Expert Comment

by:cezarF
ID: 20277590
0
 
LVL 30

Accepted Solution

by:
Alexandre Simões earned 500 total points
ID: 20279575
Threads can be Sync or Async.
The difference it that Sync is like inline code, Async work on a parallel processing, tho not waiting for it to finish.

Create the delegate and call BeginInvoke(), this will call the method on a separated thread.
Simply calling Invoke() will start a Sync processing and your code will still stop for the method to finish.

Be careful about UI... you cannot modify controls on a thread other than the one where they were created, that usually is the main thread. This means that every object that have visual representation cannot be changed on a different thread that the one where it was created.

This Google search returns a good set of articles about delegates.
http://www.google.pt/search?q=vb.net+delegates&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a

Cheers,
Alex
0

Featured Post

Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question