简体   繁体   English

如何创建子进程以执行C#中的方法?

[英]How to create child process to execute a method in c#?

I have got an logical bug from winpcap library in reading file from offline dump file . 我从winpcap库中读取脱机转储文件中的文件有一个逻辑错误。 In that they are not closing the file after reading. 因为他们在读取后没有关闭文件。 So i am getting an exception that "failed to open the file" when file count reaches 509. 因此,当文件数达到509时,我遇到了一个“无法打开文件”的异常。

I am using pcap.net library with c#. 我正在C#中使用pcap.net库。 Here is my code 这是我的代码

OfflinePacketDevice selectedDevice = new OfflinePacketDevice(filename);
PacketCommunicator communicator = selectedDevice.Open(65536,PacketDeviceOpenAttributes.Promiscuous,1000);    
communicator.ReceivePackets(0, DispatcherHandler);
communicator.Dispose();

Now i need to execute the above statements as a child process ,so i think i can avoid that exception by calling the child processs for each pcap file. 现在我需要将以上语句作为子进程执行 ,因此我认为我可以通过为每个pcap文件调用子进程来避免该异常。 But i don't know how to execute a metho as child process in c#. 但是我不知道如何在C#中执行作为子进程的方法。 Can any one give me a solution for this ? 有人可以给我解决方案吗?

As for the alleged WinPcap library bug, the program reading the dump file is calling pcap_close() after it reads the last packet of the file, right? 至于所谓的WinPcap库错误,读取转储文件的程序在读取文件的最后一个数据包后正在调用pcap_close() ,对吗? If not, the bug is in the program, not in WinPcap. 如果不是,则该错误位于程序中,而不在WinPcap中。 Even if so, the bug might be in pcap.net, not WinPcap. 即使这样,该错误也可能存在于pcap.net中,而不是WinPcap中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM