473,398 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 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 1683
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Al Christoph | last post by:
I have a program that mixes wizard like behavior with random access to the various dialogs in the wizard. I do this by having each step map to a toolstripmenuitem. Users can randomly choose the...
15
by: Bryan | last post by:
I have a multi-threaded C# console application that uses WMI (System.Management namespace) to make RPC calls to several servers (600+ ) and returns ScheduledJobs. The section of my code that...
0
by: han zhiyang | last post by:
I've just studied the "how to" web service and the async pattern in donnet.I make a test with these knowledges,but I got a strange result. Here is my test. 1.Write a simple "Add" service named...
1
by: Lak | last post by:
Hi all I am trying to call a method from a C# dll asynchronously from VB. I don't know how to do this. Please get back to me with your suggestions. Thanks.
1
by: JamesK | last post by:
Hi there, Hoping someone might have an idea of whats going on here, I presume I'm in the right forum but not 100%. I have a java web service that I am using with a C# .NET client. ...
4
by: Edwin Gomez | last post by:
I'm a C# developer and I'm new to Python. I would like to know if the concept of Asynchronous call-backs exists in Python. Basically what I mean is that I dispatch a thread and when the thread...
0
by: =?Utf-8?B?dGhlamFtaWU=?= | last post by:
In the sample VB application for Filestream.BeginWrite Method, there is no NEW implementation on the AsyncCallBack Object and sample below calls for declaring both the "State" object and the...
9
by: Pubs | last post by:
Hi all, I want to call a function with some intial parameters with in a thread. At the end of the function execution it should return a value to the caller. Caller is outside the thread. ...
3
by: John Skandar | last post by:
I've found a free WebService on the net for a currency converter and have created a class to use it with the WSDL tool. I call the WebService method asynchronously: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.