C# 中的分叉概念
既然C#支持线程,那么有没有办法在C#中实现fork概念呢?
提前致谢....
Since C# supports threading, is there any way to implement fork concept in C#?
Thanks in advance....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这更多的是 .NET / CLR 的问题,而不是 C# 的问题。一般来说,这是底层操作系统的问题。 Windows 不支持类似于
fork()
的生成新进程的语义。另外,fork() 与多线程支持无关。fork()
的语义涉及复制原始进程地址空间的内容。我的观点是,这是一种过时的进程创建方法,在 Windows 世界中几乎没有任何空间,因为它涉及很多安全和操作系统体系结构问题。从 .NET 的角度来看,
fork()
的根本问题是复制和/或共享非托管资源(文件句柄、同步对象、窗口句柄 (!) 等)的方法。新旧流程之间。我认为没有充分的理由将这样的概念引入.NET 或底层Windows 操作系统。有关进一步讨论,请参阅 saurabh 的链接。
This is more a matter of .NET / CLR than of C#. Generally, it's a matter of the underlying operating system. Windows do not support
fork()
-like semantics of spawning new processes. Also,fork()
has nothing to do with multithreading support.The semantics of
fork()
involves duplicating the contents of the original process's address space. My opinion is this is an obsolete approach to process creation and has barely any room in the Windows world, because it involves a lot of security and operating system architecture concerns.From the .NET point of view, the fundamental problem with
fork()
would be the approach to duplicating and/or sharing unmanaged resources (file handles, synchronization objects, window handles (!), etc.) between the old and the new process. I think there is no serious reason to introduce such concept either to .NET or to the underlying Windows operating system.For further discussion see saurabh's link.