Re: Problem with threads

Alexander Olk <[email protected]> Sat, 30 Apr 2005 21:46:10 +0200
Newsgroups gmane.comp.lib.wxwindows.wxnet
Message-ID <[email protected]>
One more...

I've added a new sample to cvs, it is called Thread.

It shows a frame with a big button. The thread updates the label of the
button. Start the thread from the menu.

Regards
Alexander Olk

Am Samstag, den 30.04.2005, 18:07 +0200 schrieb Alexander Olk:
> There is now an other possibility in cvs:
> 
> you can add 
> 
> ObjectDeleted = new ObjectDeletedHandler(MyCppObjectDoesntLiveAnymore);
> 
> to your ctor...
> 		
> public void MyCppObjectDoesntLiveAnymore()
> {
> 	Console.WriteLine("Oh, it's gone...");
> }
> 
> Regards
> Alexander Olk
> 
> Am Samstag, den 30.04.2005, 16:46 +0200 schrieb Alexander Olk:
> > Am Samstag, den 30.04.2005, 15:26 +0200 schrieb Radek Podgorny:
> > > Thanks but this wouldn't solve my problem. I don't want to touch c++.
> > > 
> > > As far as I understand it correctly, the problem is that all the child windows 
> > > (pointers to them) are stored in the c++ part of wxnet. When I call the 
> > > wx.Frame C# destructor, it calls the underlaying c++ destructor which takes 
> > > all the children and destroys them (in c++). So, when I overload the 
> > > wx.Button destructor (or Dispose or whatever) which is wx.Frame's child in C# 
> > > it's pretty useless because it's never called, right?
> > > 
> > > How do we solve this? If it's really like this the entire wx-net wrapper is 
> > > useless :-(
> > 
> > If you look at the c++ wrapper for wxButton you'll find
> > DECLARE_OBJECTDELETED(_Button) in class _Button.
> > 
> > What does DECLARE_OBJECTDELETED do ?
> > 
> > DECLARE_OBJECTDELETED is a macro that implements the following code:
> > 
> > #define DECLARE_OBJECTDELETED(name) \
> >     virtual ~name() \
> >     { \
> >         FunctionEvent e(wxEVT_OBJECTDELETED); \
> >         ProcessEvent(e); \
> >     }
> > 
> > If the button dtor gets called (c++) a "object deleted" event will be generated.
> > You can catch this event with 
> > 
> > // add the next line to your Button class ctor
> > AddEventListener(Event.wxEVT_OBJECTDELETED, new EventListener(OnObjectDeleted));
> > 
> > public void OnObjectDeleted(object sender, Event evt)
> > {
> > 	// stop a thread, do someting else here, 
> > 	// change the value of a thread_is_running variable,
> > 	// turn on the coffee machine,
> > 	// or whatever you want...
> > }
> > 
> > Hope that helps.
> > 
> > Regards
> > Alexander Olk
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > -------------------------------------------------------
> > This SF.Net email is sponsored by: NEC IT Guy Games.
> > Get your fingers limbered up and give it your best shot. 4 great events, 4
> > opportunities to win big! Highest score wins.NEC IT Guy Games. Play to
> > win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20
> > _______________________________________________
> > wxnet-users mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/wxnet-users
> 
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by: NEC IT Guy Games.
> Get your fingers limbered up and give it your best shot. 4 great events, 4
> opportunities to win big! Highest score wins.NEC IT Guy Games. Play to
> win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20
> _______________________________________________
> wxnet-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/wxnet-users



-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.
Get your fingers limbered up and give it your best shot. 4 great events, 4
opportunities to win big! Highest score wins.NEC IT Guy Games. Play to
win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20