Its seems like in your stop button click you are accessing Manager.ThreadList.Keys
and its static object (it means handled by System) so when you are using dictionary object its modifiable. SO here situation is that one function is continuously modifying that collection and meanwhile stop_Click is using it...
So here you can do one thing ...
private void Stop_Click(object sender, EventArgs e)
{
try
{
Dictionary<thread,> TempThreadList = new Dictionary<thread,>();
while(Manager.ThreadList.Keys.Count > 0)
{
TempThreadList=Manager.ThreadList;
foreach (Thread t in TempThreadList.Keys)
{
if (t.ThreadState == System.Threading.ThreadState.Running)
t.Abort();
}
}
MessageBox.Show("All operations canceled successfully.");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}