C
Claire
I was ok understanding threads in Delphi pre .net, but reading through a
reference book and comparing it to what help file says has confused me
A System.Threading.Timer thread in one class calls an event in a 2nd class
as follows (fast timer)
public void OnDriverSendResult(rackdetail RackDetail)
{
// Add new RackDetail to linked list and leave quickly
RackDetail.Previous = this.LastDetail;
if (this.LastDetail == null)
this.FirstDetail = RackDetail;
else
this.LastDetail.Next = RackDetail;
this.LastDetail = RackDetail;
}
In the 2nd class, I will have another system.threading.timer thread (slow
timer) that takes the linked list created by the first timer, processes the
data in it and posts it to a database.
private void ProcessList()
{
if (FirstDetail == null) return;
RackDetail Unprocessed = FirstDetail;
FirstDetail = null;
Processed = Process(Unprocessed);
Post(Processed);
}
How do I protect shared variables/objects in .net threads please. Some code
samples would be more useful to me in the first instance.
thanks
Claire
reference book and comparing it to what help file says has confused me
A System.Threading.Timer thread in one class calls an event in a 2nd class
as follows (fast timer)
public void OnDriverSendResult(rackdetail RackDetail)
{
// Add new RackDetail to linked list and leave quickly
RackDetail.Previous = this.LastDetail;
if (this.LastDetail == null)
this.FirstDetail = RackDetail;
else
this.LastDetail.Next = RackDetail;
this.LastDetail = RackDetail;
}
In the 2nd class, I will have another system.threading.timer thread (slow
timer) that takes the linked list created by the first timer, processes the
data in it and posts it to a database.
private void ProcessList()
{
if (FirstDetail == null) return;
RackDetail Unprocessed = FirstDetail;
FirstDetail = null;
Processed = Process(Unprocessed);
Post(Processed);
}
How do I protect shared variables/objects in .net threads please. Some code
samples would be more useful to me in the first instance.
thanks
Claire