c# event handler is called multiple times when event is raised once

前端 未结 4 1655
-上瘾入骨i
-上瘾入骨i 2021-01-05 04:42

Below is my code, first is where I raise the event and second section is where I consume it in another class. It seems pretty straight forward, but the logs are showing that

4条回答
  •  长发绾君心
    2021-01-05 05:11

    I had the same problem, register your event in a synchronous method ( I put it in form_loaded)

        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            RefreshHierarchy.COIDConflict += RefreshHierarchy_COIDConflict;
        }
    

提交回复
热议问题