简体   繁体   English

在运行backgroundworker时不会触发Excel Worksheet事件

[英]Excel Worksheet events don't fire when backgroundworker is running

I have a backgroundworker that is running a heavy task. 我有一名背景工作人员正在执行繁重的任务。 While it runs the user can do some stuff in the UI like change the value of an Excel cell. 在运行时,用户可以在UI中做一些事情,例如更改Excel单元格的值。 There are also events like WorksheetChange event configured. 还配置了类似WorksheetChange事件的事件。

Now when the backgroundworker is running, these events do not get fired until the backgroundworker completes its execution. 现在,当后台工作程序正在运行时,直到后台工作程序完成执行之后,才会触发这些事件。 Why is that so? 为什么会这样? Why is a separate thread blocking Excel events? 为什么有单独的线程阻止Excel事件?

Stupid mistake. 愚蠢的错误。 The function that the backgroundworker calls was disabling the application events this.Application.EnableEvents = false; 后台工作人员调用的功能是禁用应用程序事件this.Application.EnableEvents = false;。

Hence, until it completed its work the other events wouldn't fire 因此,在完成工作之前,其他事件不会触发

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM