TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
patrick
NA
397
0
Binary stream access manager.
Jul 30 2009 10:25 AM
Here Is the code I am using: (I know the empty catches shouldnt be there)
public static void serializeAndStoreOrder(Order O)
{
List
orderList = new 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
)binaryFormatter.Deserialize(fileStream);
}
}
}
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
orderList = new List
(10);
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
)binaryFormatter.Deserialize(fileStream);
}
}
}
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.
Reply
Answers (
0
)
How to do two processes at the same time????
Programmatically set up a web server