public static void serializeAndStoreOrder(Order O)
{
List
BinaryFormatter binaryFormatter = new BinaryFormatter();
try
{
using (FileStream fileStream = new FileStream(Properties.Settings.Default.OrdersLocation+"\\Orders.dat", FileMode.OpenOrCreate, FileAccess.Read))
{
if (fileStream.Length > 0)
{
orderList = (List
}
}
}
catch
{
}
orderList.Add(O);
try
{
using (FileStream fileStream = new FileStream(Properties.Settings.Default.OrdersLocation + "\\Orders.dat", FileMode.OpenOrCreate, FileAccess.Write))
{
binaryFormatter.Serialize(fileStream, orderList);
}
}
catch
{
}
}
public static Order retrieveOldOrder(int orderNumber)
{
Order O = new Order();
List
BinaryFormatter binaryFormatter = new BinaryFormatter();
try
{
using (FileStream fileStream = new FileStream(Properties.Settings.Default.OrdersLocation + "\\Orders.dat", FileMode.OpenOrCreate, FileAccess.Read))
{
if (fileStream.Length > 0)
{
orderList = (List
}
}
}
catch
{
}
for (int i = 0; i < orderList.Count; i++)
{
if (orderList[i].OrderId == orderNumber)
{
O = orderList[i];
}
}
return O;
}
What I need is to make this code able to handle 2 or more computers accessing it at once, either by allowing an open connection or by retying until it can successfully add the order.

Answers
Know the answer? Post it. Somebody with the same question will find it here.