Click here to Skip to main content
15,889,335 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralWindows mobile 2003 for Pocket PC Pin
Member 123796715-Jul-04 3:37
Member 123796715-Jul-04 3:37 
GeneralRe: Windows mobile 2003 for Pocket PC Pin
Roman Rodov15-Jul-04 15:03
Roman Rodov15-Jul-04 15:03 
GeneralBehavior of RichTextBox Pin
mav.northwind14-Jul-04 9:48
mav.northwind14-Jul-04 9:48 
GeneralRegistry entry for date of installation Pin
vipul_vips13-Jul-04 20:58
vipul_vips13-Jul-04 20:58 
GeneralRe: Registry entry for date of installation Pin
Serge Lobko-Lobanovsky16-Jul-04 6:30
Serge Lobko-Lobanovsky16-Jul-04 6:30 
Generaluse of attributes to modify method behavior Pin
Mahasen Bandara13-Jul-04 20:54
Mahasen Bandara13-Jul-04 20:54 
GeneralRe: use of attributes to modify method behavior Pin
Sendilkumar.M20-Jul-04 0:31
Sendilkumar.M20-Jul-04 0:31 
GeneralInterop: inter thread communication and array issue Pin
RLebrun13-Jul-04 3:52
RLebrun13-Jul-04 3:52 
Hello, I am a newbie in interoperability, and I met a problem with SAFEARRAY in inter-thread communication; unfortunately, I found nothing close to this problem on the Internet.

To summarize:
I have exposed .NET classes to COM clients, one of the classes has an array has returned method value. And in COM (C++) it seems that passing a SAFEARRAY of n "myObject" from a worker thread to a UI thread fails whereas passing n times a single "myObject" works perfectly.

I want to know if something must be done on the c# array which is exposed to COM to solve that.


For those who met this problem (or are courageous), here are the details:

In C#, I have 3 classes "MyObject1","MyObject2" and "MyObject3".
"MyObject1" has a method which returns an array of "MyObject2": public MyObject2[] getArray();
"MyObject2" has a method which returns an instance of "MyObject3": public MyObject3 getObject3();
"MyObject3" has several methods which returns its id, name...

Now, I expose this managed code in a dll to unmanaged code, C++, with .NET framework interop fonctionalities.
In C++, I get:
"MyObject1->getArray()" has a safearray of MyObject2 as returned value
"MyObject2->getObject3()" has MyObject3 as returned value
Great! My managed code is exposed to COM clients!

Now the bug:
In C++, I have 2 threads "UI" and "worker", both are COINIT_APARTMENTTHREADED.
1. I create an instance of "MyObject1" in the UI thread
2. I pass this object to a worker thread method through a queue list
3. In that worker thread method, I call "MyObject1->getArray()" and get the SAFEARRAY of "MyObject2" as returned value
4. I pass back that safearray to a method callback of the UI thread
5. In that UI callback, I want to iterate on the safearray: for each "MyObject2" of the array, I call "MyObject2->getObject3()", then a method of "MyObject3"
-> bug: whatever the method of "MyObject3" which is called, it fails: it seems that "MyObject3" has a problem.

I have made some extra tests:
1. Test1: I put COINIT_MULTITHREADED to UI AND worker: no problem. But this patch cannot be used.
2. Test2: if I do steps 2-to-5 in the worker thread (which means I iterate the safearray in the worker thread, and never go back in the UI): no problem
3. Test3: if I do steps 2-to-5 in the UI thread (which means I never go into worker): no problem
4. Test4:
At step 3, I iterate on the SAFEARRAY. For each "MyObject2" of the array, I pass it to an other callback of the UI. Then, in the UI, I call "MyObject2->getObject3()" and then any methods of "MyObject3", and it is working!

That means that passing a SAFEARRAY of n "MyObject2" from worker to UI fails when we want to retrieve objects from each "MyObject2", but passing n times a single "MyObject2" works perfectly.

I wonder if I have something to add to my C# code so the marshalling/unmarshalling of the array works between threads.

Renaud


GeneralSerial port in Windows CE Pin
shayro13-Jul-04 1:03
shayro13-Jul-04 1:03 
QuestionHow to capture requests and responses Pin
shanit12-Jul-04 17:25
shanit12-Jul-04 17:25 
AnswerRe: How to capture requests and responses Pin
Javier Lozano20-Jul-04 12:51
Javier Lozano20-Jul-04 12:51 
GeneralA serious bug of list View in compact framework Pin
ting66812-Jul-04 0:15
ting66812-Jul-04 0:15 
GeneralPocketPC to Smart Phone Pin
Nefertiti11-Jul-04 18:36
Nefertiti11-Jul-04 18:36 
GeneralReflection-[Waiting for 2 days ] Pin
Sendilkumar.M9-Jul-04 21:13
Sendilkumar.M9-Jul-04 21:13 
GeneralRe: Reflection-[Waiting for 2 days ] Pin
Roman Rodov15-Jul-04 15:16
Roman Rodov15-Jul-04 15:16 
GeneralTHANKING YOU Pin
Sendilkumar.M15-Jul-04 17:31
Sendilkumar.M15-Jul-04 17:31 
Generallike PotMssage and User define message Pin
kobybr9-Jul-04 9:11
kobybr9-Jul-04 9:11 
GeneralRe: like PotMssage and User define message Pin
mav.northwind9-Jul-04 22:34
mav.northwind9-Jul-04 22:34 
GeneralAccepting date values Pin
Richard Jones9-Jul-04 2:33
Richard Jones9-Jul-04 2:33 
GeneralRe: Accepting date values Pin
Richard Jones12-Jul-04 7:18
Richard Jones12-Jul-04 7:18 
Generalraising an event Pin
Member 11412669-Jul-04 2:14
Member 11412669-Jul-04 2:14 
GeneralRe: raising an event Pin
mav.northwind9-Jul-04 22:26
mav.northwind9-Jul-04 22:26 
GeneralRe: raising an event Pin
Member 114126612-Jul-04 0:24
Member 114126612-Jul-04 0:24 
GeneralRe: raising an event Pin
mav.northwind12-Jul-04 2:00
mav.northwind12-Jul-04 2:00 
GeneralNew .NET Pin
Brendan Vogt8-Jul-04 23:26
Brendan Vogt8-Jul-04 23:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.