private static void DOWork()
{
FilePosition = 0;
// Loop until either until the end of file is reached or user requested to stop
while ((KeepGoing == true) && (FilePosition < TotalFileSizeBytes))
{
// OK user requested that we terminate
// recording, so lets do it
if (RequestStop == true)
KeepGoing = false;
else
{
// If not paused
if (Replay_Status == ReplayStatus.Replaying)
{
try
{
// Lets determine the size of the block
int BlockSize = BinaryReader.ReadInt32();
// Now determine the time since the last data block
int TimeBetweenMessages = BinaryReader.ReadInt32();
// Now read the data block as indicated by the size
byte [] Data_Block_Buffer = BinaryReader.ReadBytes(BlockSize);
// Wait the same time as in the orignal data set or faster as indicated by the
// replay speed factor
Thread.Sleep(TimeBetweenMessages / ReplaySpeed);
// Send the data to the specifed interface/multicast address/port
tx_sock.Send(Data_Block_Buffer, Data_Block_Buffer.Length, tx_iep);
// Assign file position
FilePosition = BinaryReader.BaseStream.Position;
}
catch(Exception e)
{
MessageBox.Show(e.Message);
}
}
}
}
FrmReplayForm ReplayForm = Application.OpenForms["FrmReplayForm"] as FrmReplayForm;
ReplayForm.NotifyReplayCompleted();
Cleanup();
}