c# - How do I execute a block of code with PostSharp when the application exits? -


वर्तमान में, मैं विधि नाम को OnMethodBoundaryAspect.OnExit विधि में जाँच रहा हूँ:

  [ सीरियलिज़ेबल] पब्लिक क्लास टाइमर ऍटिट्यूड: OnMethodBoundaryAccpect {सार्वजनिक ओवरराइड रिक्त ओएनएक्सिट (MethodExecutionEventArgs eventArgs) {यदि (eventArgs.Method.DeclaringType.Name == "प्रोग्राम" और amp; eventArgs.Method.Name == "मेन") // do things }}  

जाहिर है, यह बदसूरत है और कुल्डी लगता है। क्या PostSharp के साथ आवेदन बाहर निकलने का पता लगाने का एक और मजबूत तरीका है?

मुझे नहीं लगता कि आपको उपयोग करना चाहिए ऐसा करने के लिए PostSharp।

आप पता लगा सकते हैं कि क्या एप्लिकेशन डोमेन सिस्टम .AppDomain की कुछ विशेषताओं का उपयोग करके बाहर निकल रहा है:

  • AppDomain.IsFinalizingForUnload ()
  • < Li> AppDomain.ProcessExit
  • AppDomain.DomainUnload

Comments

Popular posts from this blog

asp.net - Change the driver in the connection string to a data source in VB.Net -

Getting started consuming web services in a Ruby on Rails 3 application -

objective c - iPhone and it's wireless area -