private void RegisterEvent() { this.TreeView.SelectionChanged += (s, e) => { var item = treeView.GetSelectedNode(); var label = item.NodeName; System.Threading.Tasks.Task.Delay(200).ContinueWith((arg) => { if (!_reset) { CakeHelper.ExecuteCmd(label, _solution); System.Threading.Tasks.Task.Delay(20).ContinueWith((_) => { CakeHelper.ActivateCmd(); }); } _reset = false; }); }; }