471,337 Members | 860 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

calling a C# method asynchronously from VB

Lak
Hi all
I am trying to call a C# method (in a DLL) asynchronously from VB. I don't
know how to do this. Any suggestion is appreciated. Thanks.
Jan 17 '06 #1
6 1587
Lak wrote:
I am trying to call a C# method (in a DLL) asynchronously from VB. I don't
know how to do this. Any suggestion is appreciated. Thanks.


Do you mean VB6 or VB.NET?

Jon

Jan 17 '06 #2
Lak
VB6.0

"Jon Skeet [C# MVP]" wrote:
Lak wrote:
I am trying to call a C# method (in a DLL) asynchronously from VB. I don't
know how to do this. Any suggestion is appreciated. Thanks.


Do you mean VB6 or VB.NET?

Jon

Jan 17 '06 #3
Lak wrote:
VB6.0


Ah. That makes life a bit harder - and I can't help you. I suggest you
wait a while for answers in this group, and if nothing helpful comes
along, try asking again in the .interop group.

Jon

Jan 17 '06 #4
Please define what you mean with 'asynchronously', your only option to call
into C# is through COM interop and such method calls are always synchronous.

What exactly are you trying to achieve?

Willy.


"Lak" <La*@discussions.microsoft.com> wrote in message
news:0D**********************************@microsof t.com...
| VB6.0
|
| "Jon Skeet [C# MVP]" wrote:
|
| > Lak wrote:
| > > I am trying to call a C# method (in a DLL) asynchronously from VB. I
don't
| > > know how to do this. Any suggestion is appreciated. Thanks.
| >
| > Do you mean VB6 or VB.NET?
| >
| > Jon
| >
| >

Jan 17 '06 #5
Lak
I have a C# method that will run for a while. While it runs, I don't want to
lock up the GUI. I need to retrieve some progress information from the C#
DLL. Therefore, I want to run the first method asynchronous so that I can use
another method to retrieve progress info. Does this help? Thanks for your
reply.

"Willy Denoyette [MVP]" wrote:
Please define what you mean with 'asynchronously', your only option to call
into C# is through COM interop and such method calls are always synchronous.

What exactly are you trying to achieve?

Willy.


"Lak" <La*@discussions.microsoft.com> wrote in message
news:0D**********************************@microsof t.com...
| VB6.0
|
| "Jon Skeet [C# MVP]" wrote:
|
| > Lak wrote:
| > > I am trying to call a C# method (in a DLL) asynchronously from VB. I
don't
| > > know how to do this. Any suggestion is appreciated. Thanks.
| >
| > Do you mean VB6 or VB.NET?
| >
| > Jon
| >
| >

Jan 17 '06 #6
Lak,

The problem with this involves the threading model that is inherent to
VB.

While you could start an asynchronous operation in VB (calling a .NET
component) and then provide some sort of callback, the problem is that you
have to call back on the thread that the component was created on. This
presents a problem.

The easiest way to do this would be to create an interface that
represents the callback which your VB component will implement. You then
pass this interface in a call to start the asynchronous operation. You can
then pass this interface to your thread, which will call back on the
interface.

The only problem here is that you have to marshal the interface
correctly, using the global interface table. You can do this using the
IGlobalInterfaceTable interface (through COM interop), or the
CoMarshalInterThreadInterfaceInStream function.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Lak" <La*@discussions.microsoft.com> wrote in message
news:89**********************************@microsof t.com...
I have a C# method that will run for a while. While it runs, I don't want
to
lock up the GUI. I need to retrieve some progress information from the C#
DLL. Therefore, I want to run the first method asynchronous so that I can
use
another method to retrieve progress info. Does this help? Thanks for your
reply.

"Willy Denoyette [MVP]" wrote:
Please define what you mean with 'asynchronously', your only option to
call
into C# is through COM interop and such method calls are always
synchronous.

What exactly are you trying to achieve?

Willy.


"Lak" <La*@discussions.microsoft.com> wrote in message
news:0D**********************************@microsof t.com...
| VB6.0
|
| "Jon Skeet [C# MVP]" wrote:
|
| > Lak wrote:
| > > I am trying to call a C# method (in a DLL) asynchronously from VB.
I
don't
| > > know how to do this. Any suggestion is appreciated. Thanks.
| >
| > Do you mean VB6 or VB.NET?
| >
| > Jon
| >
| >

Jan 17 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Edwin Gomez | last post: by
reply views Thread by =?Utf-8?B?dGhlamFtaWU=?= | last post: by
9 posts views Thread by Pubs | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.