I have the following code:
void ReferenceManager_DoWork(object sender, DoWorkEventArgs e)
{
try
{
byte[] data = this.GetData(IvdSession.Instance.Company.Description, IvdSession.Instance.Company.Password);
List<T> deseriaizedList = null;
using (MemoryStream ms = new MemoryStream(data))
{
deseriaizedList = Serializer.Deserialize<List<T>>(ms);
}
List<IReference> referenceList = new List<IReference>();
foreach (T entity in deseriaizedList)
{
IReference reference = (IReference)entity;
referenceList.Add(reference);
}
e.Result = referenceList;
}
catch (WebException)
{
e.Result = null;
}
}
Basically, the code calls the delegate for the WebService method. Unfortunately, the main reason I used the background worker was to stop freezing the user interface when loading data. I have a form that appears, saying please wait, click here to cancel.
When I click cancel, I call CancelAsync on the desktop background. Now that I am not looping, I donβt see a good way to check for cancellation. The only option I see is to have ...
byte[] m_CurrentData;
... DoWork (..), - m_CurrentData. , m_CurrentData .
?