这是我的代码使用bwpickup
是后台工作者的名字,代码是后台工作者的开始
if (bwPickUp.IsBusy)
{
bwPickUp.CancelAsync();
}
if (!bwPickUp.IsBusy)
{
if (txtPickUpPostCode.Text.Trim() != "")
{
txtPickUpAddress.Text = "";
}
bwPickUp.RunWorkerAsync();
}
在后台工作者代码的DoWork方法中:
if (bwPickUp.CancellationPending)
{
e.Cancel = true;
return;
}
if (txtPickUpPostCode.Text.Trim() != "")
{
try
{
GoogleApi gapi = new GoogleApi();
_PickUpAddress = gapi.FindAdrressUsingPostCode(txtPickUpPostCode.Text);
}
catch (Exception)
{
}
}
请帮我解决如何阻止后台工作人员的问题