Midhat Ademovic

Midhat Ademovic

  • NA
  • 3
  • 1.5k

Is this safe

Oct 17 2011 8:13 AM
I need to communicate with fiscal printer via third party software (Don't ask me way).
I'm sending command file in one folder and receive answer file in another folder.

My print method need to return number of fiscal invoice which is generated by printer and can be found in answer file.

So my method look like this

public int PrintInvoice()
{

//Do some code of sending command file


//Wait until answer file received

while(!_answerFileReceived){}


//Process answer file and return Invoice number

}

Also I have FileSystemWatcher which monitor answer directory (file creation) with code

fswWatcher_FileCreated(object sender, FileSystemEventArgs e)
{

_answerFileReceived = true;

}

My question is "Is this safe" and can I have exceptions, or do you have any suggestion of another approach to above problem.

Thank you.

Answers (6)