I'm refactoring some code I inherited from a long-gone developer, and I find this:
我正在重构一些我从一个已经过时的开发人员继承的代码,我发现这个:
ImportExportForm l_Form = new ImportExportForm();
l_Form.InitializeLifetimeService();
l_Form.ShowDialog();
I've never seen or used the LifetimeService before, but from the little I've read, I don't understand why I would want to use it here, but before saying WTF, I wondered if I might be missing some subtle detail?
我之前从未见过或曾经使用过LifetimeService,但是从我读过的那篇文章中,我不明白为什么我会在这里使用它,但在说WTF之前,我想知道我是否会遗漏一些微妙的细节?
2 个解决方案
#1
4
As far as I know this is a method normally use for Remote .Net Objects, and to establish the lifetime of an instance. Look here:
据我所知,这是一种通常用于远程.Net对象的方法,并用于建立实例的生命周期。看这里:
http://msdn.microsoft.com/es-es/magazine/cc300474(en-us).aspx
I don't think that it's important for normal Windows Form.
我认为这对于普通的Windows窗体来说并不重要。
#2
1
True, it is used for .Net remoting, like WCF. Except if your object ImportExportForm is loading something remotely, i don't see any reason to use this. See there: http://msdn.microsoft.com/en-us/library/23bk23zc(v=vs.100).aspx
没错,它用于.Net远程处理,就像WCF一样。除非您的对象ImportExportForm正在远程加载某些内容,否则我认为没有任何理由使用它。请参阅:http://msdn.microsoft.com/en-us/library/23bk23zc(v = vs.100).aspx
#1
4
As far as I know this is a method normally use for Remote .Net Objects, and to establish the lifetime of an instance. Look here:
据我所知,这是一种通常用于远程.Net对象的方法,并用于建立实例的生命周期。看这里:
http://msdn.microsoft.com/es-es/magazine/cc300474(en-us).aspx
I don't think that it's important for normal Windows Form.
我认为这对于普通的Windows窗体来说并不重要。
#2
1
True, it is used for .Net remoting, like WCF. Except if your object ImportExportForm is loading something remotely, i don't see any reason to use this. See there: http://msdn.microsoft.com/en-us/library/23bk23zc(v=vs.100).aspx
没错,它用于.Net远程处理,就像WCF一样。除非您的对象ImportExportForm正在远程加载某些内容,否则我认为没有任何理由使用它。请参阅:http://msdn.microsoft.com/en-us/library/23bk23zc(v = vs.100).aspx