Reply To: C# Wait?

Home Forums Discussions Support Portal C# Wait? Reply To: C# Wait?

#9588

Vadim Smirnov
Moderator

Just add Console.ReadKey() before forwarding packet to the network interface. Below is a part of PassThru C# sample with Console.ReadKey() added.

Please note, that all the networking for the selected network interface will be frozen while console waits for the input…

while (packetsCount > 0)
{
	manualResetEvent.WaitOne();

	while (Ndisapi.ReadPacket(driverPtr, ref request))
        {
        	--packetsCount;

                buffer = (INTERMEDIATE_BUFFER)Marshal.PtrToStructure(bufferPtr, typeof(INTERMEDIATE_BUFFER));

                WriteToConsole(buffer, bufferPtr);

                if (buffer.m_dwDeviceFlags == Ndisapi.PACKET_FLAG_ON_SEND)
		{
			Console.ReadKey();
	                Ndisapi.SendPacketToAdapter(driverPtr, ref request);
		}
                else
                        Ndisapi.SendPacketToMstcp(driverPtr, ref request);
        }

        manualResetEvent.Reset();
}