[Mono-osx] Registering an NSThread with Mono
Kevin Heeney
koheeney at gmail.com
Wed Nov 26 20:20:46 EST 2008
Okay, so I think it is an issue somehow with how I am invoking Mono.
When being called from the main thread, the following code works.
When being called from a separate thread, on the same object,
mono_string_to_utf8 (val) below returns NULL but does not throw an
exception.
mono_thread_attach(domain);
MonoClassField *field;
MonoString* val;
field = mono_class_get_field_from_name (myMonoclass, [FieldName
UTF8String]);
mono_field_get_value (myMonoObject, field, &val);
char *p;
p = mono_string_to_utf8 (val); //p here will be null when being
called from a secondary thread.
NSString* retStr = [[NSString alloc] initWithUTF8String:p]; //on
secondary threads, this line throws the exception "-
[NSPlaceholderString initWithUTF8String:]: NULL cString" because p is
null
return retStr;
I am doing more checks (like checking to make sure the field is
found, but I have removed that code in this sample).
Any suggestions?
Thanks,
Kevin
On Nov 26, 2008, at 1:15 PM, Kevin Heeney wrote:
> I was thinking I had to pass mono_thread_attach a reference to a
> thread. Would calling mono_thread_attach(myDomain); work? If so,
> I might have a different issue.
>
> Thanks,
> Kevin
>
> On Nov 26, 2008, at 1:03 PM, Kevin Heeney wrote:
>
>> Is there any way to register an NSThread with Mono? I am using a
>> 3rd party framework which I pass a delegate class and it launches
>> a new Thread. I have that class getting a reference to this
>> created Thread using [NSThread currentThread]. I now need to call
>> Mono from this thread but I need to register the thread using
>> "mono_thread_attach" I believe. Is there anyway that I can do
>> this with an NSThread?
>>
>> Thanks,
>> Kevin
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-osx/attachments/20081126/1360f516/attachment-0001.html
More information about the Mono-osx
mailing list