Quote:
Originally Posted by Super Aids
Instead of keeping to repeat this:
Code:
fixed (byte* Packet = Buffer)
Then you could make a property for the pointer:
Code:
public byte* Pointer
{
get
{
fixed (byte* p = Buffer)
return p;
}
}
|
The pointer is unsafe (

) The memory manager might move the managed memory after... The fixed keyword say to the memory manager to fix the memory during a period of time, after that, the pointer is no longer valid. So, everything you do on the pointer must be done inside the fixed's brackets.
Edit. For the thread itself, the code is not really faster as you're fixing the memory for each read and write... All operations should be done in one block to optimize the thing.
Or, just use unmanaged memory and/or just use a structure which will map all the buffer directly to values. (ref. COPS v6)