Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   create a COM object which supports threading (http://www.velocityreviews.com/forums/t459852-create-a-com-object-which-supports-threading.html)

unknown; 01-16-2007 08:18 AM

create a COM object which supports threading
 
hello,

i've two projects. One is a (native) C++ project building as a COM.
the other one is a VB.NEt project which will use the COM object.

both are written in Visual Studio 2005


when i call in VB.NET a function in C++ it all works fine. but this
function will take about 1 or 2 minutes and in the mean time i want to
access some properties (from the same COM object).

I thought i could fix this with a thread in VB.NET ending up with
something like this.
( i know this is VB.NET code, but it's only to explain my problem)

1) Dim a As COMLib.IcomClass = New COMLib.comClass
2) Dim t As Thread
3) t = New Thread(AddressOf a.functionIwantToCall)
4) t.Start()
5) dim i as integer
6) i = a.integerProperty

when i start my thread (4) this will work. my COM function will execute
but when this thread was started my application will not execute 5 and
6 till the COM function is finished. i think this is because VB.NET
can't execute a part of the function because it isn't a real part of my
VB.NET application

my question: how do i make a COM object which will support threading?
or how do i solve this problem?

thank you


Ian Collins 01-16-2007 08:24 AM

Re: create a COM object which supports threading
 
unknown; wrote:
> hello,
>
> i've two projects. One is a (native) C++ project building as a COM.
> the other one is a VB.NEt project which will use the COM object.
>

Off topic here, try a windows programming group.

--
Ian Collins.

William 01-17-2007 02:34 AM

Re: create a COM object which supports threading
 

make sure your COM object support multi-thread access (in 'MTA' model).

On Tue, 16 Jan 2007 16:18:31 +0800, unknown; <unknown1310@gmail.com> wrote:

> hello,
>
> i've two projects. One is a (native) C++ project building as a COM.
> the other one is a VB.NEt project which will use the COM object.
>
> both are written in Visual Studio 2005
>
>
> when i call in VB.NET a function in C++ it all works fine. but this
> function will take about 1 or 2 minutes and in the mean time i want to
> access some properties (from the same COM object).
>
> I thought i could fix this with a thread in VB.NET ending up with
> something like this.
> ( i know this is VB.NET code, but it's only to explain my problem)
>
> 1) Dim a As COMLib.IcomClass = New COMLib.comClass
> 2) Dim t As Thread
> 3) t = New Thread(AddressOf a.functionIwantToCall)
> 4) t.Start()
> 5) dim i as integer
> 6) i = a.integerProperty
>
> when i start my thread (4) this will work. my COM function will execute
> but when this thread was started my application will not execute 5 and
> 6 till the COM function is finished. i think this is because VB.NET
> can't execute a part of the function because it isn't a real part of my
> VB.NET application
>
> my question: how do i make a COM object which will support threading?
> or how do i solve this problem?
>
> thank you
>




All times are GMT. The time now is 09:07 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57