Is it possible to create a new thread and run a procedure in it which takes
a parameter to be passed in between the two threads? I need to do this
without creating a separae project or use COM.

Daniel

Re: marshal parameters without using com by Alex

Alex
Sun Jul 20 01:34:04 CDT 2008

"Daniel" wrote:
> Is it possible to create a new thread and run a procedure in it
> which takes a parameter to be passed in between the two threads?
> I need to do this without creating a separae project or use COM.

Of course it is possible. Thread procedure accepts void* optional
parameter, where you can pass whatever you wish. If you pass a
pointer to something you have to ensure that this something will
exist at least untill the new thread is started. The common
approach is to allocate the structure from heap, then to free it
in new thread.

Alex



Re: marshal parameters without using com by Daniel

Daniel
Tue Jul 22 02:39:50 CDT 2008

What commands do I need to look up in help to use to allocate a structure
for use of this purpose? I believe this is called marshalling, am I
correct?

Daniel

"Alex Blekhman" <tkfx.REMOVE@yahoo.com> wrote in message
news:OmBMnIj6IHA.3696@TK2MSFTNGP04.phx.gbl...
> "Daniel" wrote:
>> Is it possible to create a new thread and run a procedure in it which
>> takes a parameter to be passed in between the two threads? I need to do
>> this without creating a separae project or use COM.
>
> Of course it is possible. Thread procedure accepts void* optional
> parameter, where you can pass whatever you wish. If you pass a pointer to
> something you have to ensure that this something will exist at least
> untill the new thread is started. The common approach is to allocate the
> structure from heap, then to free it in new thread.
>
> Alex
>



Re: marshal parameters without using com by Igor

Igor
Tue Jul 22 06:59:56 CDT 2008

"Daniel" <newstbs@cableone.net> wrote in message
news:es%23rW486IHA.2260@TK2MSFTNGP03.phx.gbl
> What commands do I need to look up in help to use to allocate a
> structure for use of this purpose?

You allocate a structure for this purpose the same way you allocate it
for any other purpose. E.g. with new or malloc()

> I believe this is called
> marshalling, am I correct?

Well, perhaps in the very general sense of the word, but on in the
specific sense COM defines.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925



Re: marshal parameters without using com by Alex

Alex
Tue Jul 22 07:02:54 CDT 2008

"Daniel" wrote:
> What commands do I need to look up in help to use to allocate a
> structure for use of this purpose? I believe this is called
> marshalling, am I correct?

No, marshaling is completely different thing, which is related to
COM.

You allocate a structire in C++ with operator new:

struct X { ... };

X* p = new X;
...

CreateThread(..., p, ...);

Within thread procedure:

DWORD WINAPI MyThread( LPVOID lpParam )
{
X* p = (X*)lpParam;

// use p
//...

delete p;
}


HTH
Alex




Re: marshal parameters without using com by Daniel

Daniel
Tue Jul 22 10:51:02 CDT 2008

Thanks.

"Alex Blekhman" <tkfx.REMOVE@yahoo.com> wrote in message
news:%23ErjhL$6IHA.4864@TK2MSFTNGP06.phx.gbl...
> "Daniel" wrote:
>> What commands do I need to look up in help to use to allocate a structure
>> for use of this purpose? I believe this is called marshalling, am I
>> correct?
>
> No, marshaling is completely different thing, which is related to COM.
>
> You allocate a structire in C++ with operator new:
>
> struct X { ... };
>
> X* p = new X;
> ...
>
> CreateThread(..., p, ...);
>
> Within thread procedure:
>
> DWORD WINAPI MyThread( LPVOID lpParam )
> {
> X* p = (X*)lpParam;
>
> // use p
> //...
>
> delete p;
> }
>
>
> HTH
> Alex
>
>
>