I admit I'm a newbie for C# and I have the following question.
Assume you have a solution with three projects (A, B, C). Project C references B, and both B and C reference A. B is where the entry point is. I have a list in one of the classes within project A. It goes like this:
Project A:
public class ProcessDuration
{
public List<TicketTimer> DurationList = new List<TicketTimer>();
public void AddProcesstime(string Ticket, int Count, Process_Step Step, Process_Status Status, DateTime Time)
{
Ticket ccStart = new Ticket();
ccStart.RecordTime(Ticket, Count, Step, Status, Time);
DurationList.Add(ccStart);
}
...
}
Project B:
class testB
{
public TicketProcessDuration TD = new TicketProcessDuration();
TD.StartProcessMonitor(ticketMain, request.DataRecords.Count);
}
Project C:
class testC
{
TD.StartProcessMonitor(ticketMain, request.DataRecords.Count); //Error here because TD scope
}
I want to add to the list from projects B and C. So I create an object of class ProjectDuration within B. But I can't access it from project C because of the scope. I played around with making the list static and creating the object TD in project C but it gave me another problem - it maintains the list for app lifetime but i want the list to be emptied after each run. I dont want to define a function and pass the ProjectDuration object to C from B. Also know that it is a web service application so several connections may be iterating the list so I just cant clear it after one run.
What do you advice? How do i solve this problem? I also want to know how can I destroy the object TD before the garbage collector?
Any urgent help would be appreciated. Let me know if I need to read some areas to understand these situation better... but solution first!
Kind regards,