Editor.Source_Files.NativeInstance.flush C# (CSharp) Method

flush() public method

public flush ( ) : void
return void
        public void flush()
        {
            lock (this)
            {
                if (callCount == 0)
                    return;

                //Insert the EOF
                binaryWriter.Write((int)StreamInstructionTypes.STREAM_INSTRUCTION_EOF);

                IntPtr incomingPointer;

                unsafe
                {
                    InstanceManager.sync(instancePtr, bufferPointer, &incomingPointer);

                    UnmanagedMemoryStream strm = new UnmanagedMemoryStream((byte*)incomingPointer, maxCallLenght, maxCallLenght, FileAccess.Read);

                    BinaryReader reader = new BinaryReader(strm);

                    UInt32 instruction;
                    bool EOF = false;
                    while (!EOF)
                    {
                        try
                        {
                            instruction = reader.ReadUInt32();
                        }
                        catch(Exception eek)
                        {
                            Console.WriteLine("EOF is invalid!");
                            Console.WriteLine(eek.ToString());
                            break;
                        }

                        switch(instruction)
                        {
                            case (int)StreamInstructionTypes.STREAM_INSTRUCTION_CALL:
                                String cmd = StreamHelper.ReadString(reader);
                                handleEvent(cmd, reader);
                                break;
                            case (int)StreamInstructionTypes.STREAM_INSTRUCTION_EOF:
                                EOF = true;
                                break;
                        }
                    }

                    resetBuffers();
                }
            }
        }