I have a class that in one of its methods creates a new thread that makes some http requests, serializes the results, packs them up in an event object and then it Should call broadcast an event returning its data. but I can't figure out how.
the class is not a form, so it doesn't have the invoke method, and I need to pass data back to the class. I'm stuck on this.
here is a stripped down version
class someclass
{
public someclass()
{
}
//my event
public delegate void onTimelineHandler(object sender ,TimelineArgs e);
public event onTimelineHandler OnTimelineRecieved;
private void TimelineAsyncStart(string url)
{
Thread myAsyncer = new Thread(new ParameterizedThreadStart(doTimelineAsync));
string[] objar = new string[] { url, username, password };
myAsyncer.Start(objar);
}
private void doTimelineAsync(object objar)
{
string[] sa2 = (string[])objar;
string url = sa2[0];
string username = sa2[1];
string password = sa2[2];
//some stuff happens here
TimelineArgs targs = new TimelineArgs(myobject);
[B]//here I need to call the event on the class that created this thread, passing to that event the TImelineArgs object.[/B]
}
]
I could really use some help on this, threading is not my things, I learned using background worker, guess I could have done that here, but really i would like to know how this is done.