/// <summary> /// The background worker asynchronous thread method calling the worker method /// </summary> /// <param name="sender"> /// A <see cref="System.Object"/> -- the sending object /// </param> /// <param name="e"> /// A <see cref="DoWorkEventArgs"/> -- containing the arguments (a LiveRadioRequestObject) /// and the result /// </param> void DoExecuteRequest(object sender, DoWorkEventArgs e) { LiveRadioRequestObject request_object = e.Argument as LiveRadioRequestObject; e.Result = request_object; RetrieveRequest(request_object.request_type, request_object.query); }
/// <summary> /// Method executed upon the completion of the background worker method /// </summary> /// <param name="sender"> /// A <see cref="System.Object"/> -- the sending object /// </param> /// <param name="e"> /// A <see cref="RunWorkerCompletedEventArgs"/> -- not used /// </param> void OnDoExecuteRequestFinished(object sender, RunWorkerCompletedEventArgs e) { BackgroundWorker request_thread = sender as BackgroundWorker; LiveRadioRequestObject request_object = e.Result as LiveRadioRequestObject; RaiseRequestResultRetrieved(request_object.request_type, request_object.query); request_thread.DoWork -= DoExecuteRequest; request_thread.RunWorkerCompleted -= OnDoExecuteRequestFinished; }
/// <summary> /// Method capsuling the actual RetrieveRequest worker method with a background worker thread /// </summary> /// <param name="request_type"> /// A <see cref="LiveRadioRequestType"/> -- the type of the request /// </param> /// <param name="query"> /// A <see cref="System.String"/> -- the freetext query or the genre name /// </param> public void ExecuteRequest(LiveRadioRequestType request_type, string query) { BackgroundWorker request_thread = new BackgroundWorker(); request_thread.DoWork += DoExecuteRequest; request_thread.RunWorkerCompleted += OnDoExecuteRequestFinished; LiveRadioRequestObject request_object = new LiveRadioRequestObject(request_type, query); request_thread.RunWorkerAsync(request_object); }
/// <summary> /// Method capsuling the actual RetrieveRequest worker method with a background worker thread /// </summary> /// <param name="request_type"> /// A <see cref="LiveRadioRequestType"/> -- the type of the request /// </param> /// <param name="query"> /// A <see cref="System.String"/> -- the freetext query or the genre name /// </param> public void ExecuteRequest(LiveRadioRequestType request_type, string query) { BackgroundWorker request_thread = new BackgroundWorker (); request_thread.DoWork += DoExecuteRequest; request_thread.RunWorkerCompleted += OnDoExecuteRequestFinished; LiveRadioRequestObject request_object = new LiveRadioRequestObject (request_type, query); request_thread.RunWorkerAsync (request_object); }