Reputation: 558
I want to stop the method below before I start another method A and restart after the execution of the method A.
I did not find a way to stop/start this method below.
private void CheckTrsfSelect(object sender, ItemCheckedEventArgs e)
{
lvi = e.Item;
if (lvi.SubItems[2].Text == "HOTEL" && TrsfSelect == 1 &&lvi.Checked)
{
MessageBox.Show("Blabla.");
lvi.Checked = false;
}
}
lvi is a public listviewitem
Upvotes: 0
Views: 33
Reputation: 30813
Consider of using a global flag to indicate that this method is currently working to avoid duplicate call.
This way, this method cannot be called twice while it is processing the previous call.
bool CheckTrsfSelectIsProcessing = false;
private void CheckTrsfSelect(object sender, ItemCheckedEventArgs e)
{
if (!CheckTrsfSelectIsProcessing){
CheckTrsfSelectIsProcessing = true;
lvi = e.Item;
if (lvi.SubItems[2].Text == "HOTEL" && TrsfSelect == 1 &&lvi.Checked)
{
MessageBox.Show("Blabla.");
lvi.Checked = false;
}
CheckTrsfSelectIsProcessing = false;
}
}
Upvotes: 1