private void Cc_FormClosed(object sender, FormClosedEventArgs e) { if (null != this.cc) { this.cc.Dispose(); this.cc = null; } }
/// <summary> /// Method to udpate Writeback status for a given WR. This method will be called by client asyncronously. Client needs to register the event WriteBackProcessCompleted to get the notification of method completion /// </summary> /// <param name="p_wrNumber">WR number</param> /// <param name="taskId"></param> public void UpdateWriteBack(string p_wrNumber, object taskId) { string sJobIdentifier = string.Empty; this.cc = new ConfirmComplete(); this.WriteBackProcessCompleted += WritebackClass_WriteBackProcessCompleted; this.cc.enableOK = false; this.cc.statusText = "Writing data to WMIS..."; this.cc.SetDesktopLocation(0, 0); this.cc.Show(m_oApp.ApplicationWindow); this.cc.TopMost = true; this.cc.Text = "WR# " + p_wrNumber; // When the cc form closes, dispose of it properly. this.cc.FormClosed += Cc_FormClosed; InitializeWriteBackDelegates(); AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(taskId); string sUserName = m_oApp.DataContext.DatabaseUserName; string sPasswordString = m_oApp.DataContext.ViewerConnectionString.Substring(m_oApp.DataContext.ViewerConnectionString.IndexOf("Password="******"Password="******"Task ID parameter must be unique", "taskId"); } userStateToLifetime[taskId] = asyncOp; } WorkerEventHandler workerDelegate = new WorkerEventHandler(UpdateWritebackStatusWorker); workerDelegate.BeginInvoke( p_wrNumber, asyncOp, sUserName, sPasswordString, null, null ); }