C# Wait?

Home Forums Discussions Support Portal C# Wait?

Tagged: 

This topic contains 1 reply, has 2 voices, and was last updated by  Vadim Smirnov 2 weeks, 5 days ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #9587

    ZiJer
    Participant

    How to intercept outgoing packet and wait until the Console.ReadKey() be proceeded?
    So packet will not be sent until the user type anything.

    Как перехватить исходящий пакет и подождать, пока Console.ReadKey() не будет продолжено?
    Т.е. пакет не будет отправлен, пока пользователь не нажмет что нибудь.

    #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();
    }
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.