R
Raoul Minder
Hi all
I am new to threading!
I am developping a newsletter tool including a dispatch manager that
should schedule sendings. The Web layer kicks a remote object hosted by
a windows service and should 'add' a schedule (time to send, id and so
on). The result should be that I have multiple threads waiting for the
send time (with thread.sleep). Now the question: How can I abort or
change the 'time to send' if the web administrator changes the (already
scheduled) send time? In other words: How can I refer one of my already
thrown threads. Please refer to the threading question only because the
surrounding behaviour (like architecture and so on) is already given.
Thank you so much for an idea how to refer thrown threads.
For a better understanding of my question a code snipplet that - did I
mention it? - is a first try with threading:
---------------------------------
public void Schedule(string ConnectionString, int Id, DateTime
ScheduleDate)
{
_now = DateTime.Now;
_connectionString = ConnectionString;
_intSleep =
Convert.ToInt32(((TimeSpan)ScheduleDate.Subtract(_now)).TotalMilliseconds);
_id = Id;
Thread t = new Thread(new ThreadStart (RunThread));
t.Start();
}
private void RunThread()
{
if (_intSleep > 0) {Thread.Sleep(_intSleep);}
//... Send the threaded Newsletter somehow ...
}
public void ClearSchedule(string ConnectionString, int Id, DateTime
ScheduleDate)
{
//That's exactly my question (???)
}
---------------------------------
I am new to threading!
I am developping a newsletter tool including a dispatch manager that
should schedule sendings. The Web layer kicks a remote object hosted by
a windows service and should 'add' a schedule (time to send, id and so
on). The result should be that I have multiple threads waiting for the
send time (with thread.sleep). Now the question: How can I abort or
change the 'time to send' if the web administrator changes the (already
scheduled) send time? In other words: How can I refer one of my already
thrown threads. Please refer to the threading question only because the
surrounding behaviour (like architecture and so on) is already given.
Thank you so much for an idea how to refer thrown threads.
For a better understanding of my question a code snipplet that - did I
mention it? - is a first try with threading:
---------------------------------
public void Schedule(string ConnectionString, int Id, DateTime
ScheduleDate)
{
_now = DateTime.Now;
_connectionString = ConnectionString;
_intSleep =
Convert.ToInt32(((TimeSpan)ScheduleDate.Subtract(_now)).TotalMilliseconds);
_id = Id;
Thread t = new Thread(new ThreadStart (RunThread));
t.Start();
}
private void RunThread()
{
if (_intSleep > 0) {Thread.Sleep(_intSleep);}
//... Send the threaded Newsletter somehow ...
}
public void ClearSchedule(string ConnectionString, int Id, DateTime
ScheduleDate)
{
//That's exactly my question (???)
}
---------------------------------