Hi Laurent,

Thank you very much ! Using the invokes and the autoreleasepools in the handlers indeed solves my problem.

Br,

Mario

Laurent Etiemble wrote:
Hello,

According to the Microsoft documentation and the Mono source code, the
event handler should be called in the thread that launch the
BakgroundWorker (The BakgroundWorker uses an AsyncOperation to post
event message on the creator thread).

I have made a small sample to see what going on, and here is the results:
- You don't have to put a NSAutoreleasePool in the DoWork handler
unless you are manipulating Cocoa classes
- You HAVE to put a NSAutoreleasePool in the ProgressChanged handler
to avoid memory leak. Seems like the running thread is not the main
one.
- You HAVE to put a NSAutoreleasePool in the RunWorkerCompleted
handler to avoid memory leak. Seems like the running thread is not the
main one.
- You can modifiy directly label or progress indicator values on the
handler, although they are not run on the main thread (read:
dangerous). The best is to use the InvokeRequired flag and Invoke
method to avoid cross-thread problems.

Regards, Laurent Etiemble.

2009/10/1 Mario De Clippeleir <mari...@sydec.be>:
Hey,

I did use the invoke stuff on a textfield and the progressbar, and that does
remove the "autorelease" message.
However, how can i use this on the NSWindow that is showing the progressbar
(displayed as a sheet), because that one is still generating some
problems...

The application is in Multithreaded mode, but the core is written as a C#
dll, which includes the backgroundworker to report the progress, so i think
NSThreadRunner is out of the question, no ?

Br,

Mario
Kenny Clement wrote:
Hi,

The way I do it, I make sure the MonobjC objects are only used on 1
thread.
Make sure all stuff on the backgroundworker threads is pure mono only, if
you need to use MonobjC objects, throw events and invoke those on your
'cocoa' thread.

However, a better way, is probably described on the Monobjc site:

http://www.monobjc.net/index.php?page=multithreading

Is your application in Multithreaded mode?
If it already is, can you use NSThreadRunner instead of .NET
backgroundworkers?

- Kenny

Mario De Clippeleir wrote:
Hi,

I am using a backgroudworker to show progress of a task. This compiles
and runs fine (it shows the progress), however i always get a lot of
notifications : "object of class autoreleased with no pool in place".
So i defined a NSAutoreleasepool in the DoWork event and release it after
it has done all the work, but still i have the same problem.

I'm pretty much stuck here....Any help ?

Thanks,

Mario

--

*Kenny Clement
*Software Developer**

image003*
*Tel. +32 9 233 68 86
Fax +32 9 240 10 39
kenny.clem...@nomadesk.com <mailto:kenny.clem...@nomadesk.com>
twitter.com/nomadesk <http://twitter.com/nomadesk>

Confidentiality Notice:
/This message, together with any attachments, is intended only for the use
of the individual or entity to which it is addressed. It may contain
information that is confidential and prohibited from disclosure. If you are
not the intended recipient, you are hereby notified that any dissemination
or copying of this message or any attachment is strictly prohibited. If you
have received this item in error, please notify the original sender and
destroy this item, along with any attachments./

Reply via email to