Re: Register a shutdown Hook in WCF

Jeroen Frijters <[email protected]> Tue, 18 Apr 2017 13:29:00 +0000
Newsgroups gmane.comp.java.ikvm.devel
Message-ID <AM4PR08MB2627D891AFFCBC85AE77DF70A2190@AM4PR08MB2627.eurprd08.prod.outlook.com>
Hi Volker,

Thanks for trying it out. I've committed a change to use DomainUnload when running in a secondary AppDomain. Could you please try it and let me know?

Regards,
Jeroen

> -----Original Message-----
> From: Volker Berlin [mailto:[email protected]]
> Sent: Tuesday, April 18, 2017 12:04
> To: IKVM List <[email protected]>
> Subject: Re: [Ikvm-developers] Register a shutdown Hook in WCF
> 
> Hi Jeroen,
> 
> Your knowledge of .NET is an impressive one.
> 
> I have add the follow code and its work:
> 
>         static Service1() {
>             AppDomain.CurrentDomain.DomainUnload += new
> EventHandler(domain_DomainUnload);
>         }
>         static void domain_DomainUnload(object sender, EventArgs e)
>         {
>             java.lang.Class clazz =
> java.lang.Class.forName("java.lang.Shutdown");
>             java.lang.reflect.Method shutdown =
> clazz.getDeclaredMethod("shutdown");
>             shutdown.setAccessible(true);
>             shutdown.invoke(null);
>         }
> 
> The shutdown hook is needed to delete temp files that the Java VM has
> created self. Else the temp directory will be filled more and more.
> 
> Can I add this hook to the IKVM or want you do it self?
> 
> Volker
> 
> Am 14.04.2017 um 06:59 schrieb Jeroen Frijters:
> > Hi Volker,
> >
> > If at all possible, it would be better to avoid shutdown hooks, but
> calling Shutdown.shutdown() via reflection is a good workaround.
> >
> > It might be possible to improve this on the IKVM side by also trying
> to hook the AppDomain.DomainUnload event. My guess is that the WCF
> service runs in a secondary AppDomain.
> >
> > Regards,
> > Jeroen
> >
> >> -----Original Message-----
> >> From: Volker Berlin [mailto:[email protected]]
> >> Sent: Thursday, April 13, 2017 15:25
> >> To: IKVM List <[email protected]>
> >> Subject: [Ikvm-developers] Register a shutdown Hook in WCF
> >>
> >> Hi Jeroen,
> >>
> >> It look like that an exit of an WCF service does not call the
> >> shutdown hooks. What is the best what I can call on shutdown? Should
> >> I call
> >> java.lang.Shutdown.shutdown() via reflection or is there a simpler
> >> solution?
> >>
> >> http://stackoverflow.com/questions/11769673/performing-action-before-
> >> wcf-service-is-shutdown
> >>
> >> Volker
> >>
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> ---
> >> ------
> >> Check out the vibrant tech community on one of the world's most
> >> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> >> _______________________________________________
> >> Ikvm-developers mailing list
> >> [email protected]
> >> https://lists.sourceforge.net/lists/listinfo/ikvm-developers
> 
> 
> ------------------------------------------------------------------------
> ------
> Check out the vibrant tech community on one of the world's most engaging
> tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Ikvm-developers mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ikvm-developers

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot