Re: Problem with threads

Radek Podgorny <[email protected]> Sun, 1 May 2005 01:58:36 +0200
Newsgroups gmane.comp.lib.wxwindows.wxnet
Message-ID <[email protected]>
Wow! Thanks Alexander! I'm really impressed by your support. I will try this 
as soon as possible. I can't use the cvs version (since our projects are 
meant to be "production") but I'm looking forward to seeing a new wx-net 
release now that wxwidgets 2.6 is out (of course with the ObjectDeleted stuff 
included)...

Thanks again
Radek Podgorny


> 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
> _______________________________________________
> wxnet-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/wxnet-users

-- 
GnuPG key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x98E56D84
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQBCdBuv7mej6pjlbYQRApCPAKCqTQGmAXXP+Tyd5ABrVkljJtZuwgCfT3OE
e9m5McZFgN4wnyqfyZHb5IQ=
=IMv2
-----END PGP SIGNATURE-----