Without knowing the method code, it’s hard to suggest an option, but in general, get a variable (bool) that both methods will see (doing work and interrupts). When starting the executing method, assign the variable to false (meaning not to interrupt) and as the method runs, check if the state of the variable has changed to true; if it has changed, then abort the method. And in the interrupting method you assign true and that's it.
private bool _cancellation; public void Start() { _cancellation = false; // если _cancellation == true прерываемся while(!_cancellation) { // тут выполняем работу Thread.Sleep(10); } } public void Cancel() { _cancellation = true; }
Such an option will enable the correct and importantly controlled completion of the method.
I described the general principle, it can be modified for threads and other things, this is a general principle for correctly interrupting the execution of a method.
_updater.Updatemethod. Generally - no way - Grundy_updateris - Grundy