我有一个silverlight mvvm应用程序加载主视图,其中2个用户控件加载到2个ContentControls中,一个用listbox显示项目,另一个用edit编辑按钮.当我单击编辑按钮时,2个新用户控件加载到ContentControls中,一个显示要编辑的数据(EditData),另一个显示保存和取消按钮(EditAction).当我单击"保存"按钮时,它会引发一个在单独的GlobalEvents.cs类中定义的事件,如:
public event EventHandler OnSaveButtonClicked;
public void RaiseSaveButtonClicked()
{
this.OnSaveButtonClicked(this, EventArgs.Empty);
}
Run Code Online (Sandbox Code Playgroud)
并且我在其他用户控件EditData中订阅它,因为我需要通过自定义EventArgs传输该编辑数据,所以我已经放入了它的ViewModel的构造函数:
this.globalEvents.OnSaveButtonClicked += (s, e) => SaveData();
Run Code Online (Sandbox Code Playgroud)
并在保存数据中:
public void SaveData()
{
globalEvents.RaiseSaveData(EditedGuy);
}
Run Code Online (Sandbox Code Playgroud)
这会引发另一个事件,将以前的用户控件加载到其ControlContent中,并在列表框中显示已编辑的数据.多数民众赞成,但每当我点击编辑然后再次保存时,它会将事件提升两次,然后再提高3次,然后再提高4次,依此类推.我怎样才能让它只被提升一次?我认为这可能是因为每次我点击编辑,加载了一个新的用户控件实例,我不知道,也许订阅该事件,所以我试图粘贴
this.globalEvents.OnSaveButtonClicked -= (s, e) => SaveData();
Run Code Online (Sandbox Code Playgroud)
到Dispose()方法但没有成功.我怎样才能做到这一点?
我想从基于eclipse的RCP中的注释类型中删除注释类型.该列表可以在Window-> preferences-> general-> editors-Text Editors-> Annotations中找到,而且我没有注释类型:
断点(org.eclipse.cdt.debug.core.breakpoint)
断点(org.eclipse.debug.core.breakpoint)
我想删除第一个例如.有没有办法以编程方式或通过更改plugin.xml?
我更新了父 pom 以使用 Spring Boot 2.1.2 版本。在我修复的其他错误和弃用中,有一个最困扰我:
创建名为 'adminServiceImpl' 的 bean 时出错:通过字段 'taskExecutor' 表示的不满足的依赖关系;嵌套异常是 org.springframework.beans.factory.NoSuchBeanDefinitionException:没有可用的“org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor”类型的合格 bean:预计至少有 1 个 bean 有资格作为自动装配候选。依赖注解:{@org.springframework.beans.factory.annotation.Autowired(required=true), @org.springframework.beans.factory.annotation.Qualifier(value="taskExecutor")}
我的配置类如下所示:
@EnableScheduling
@EnableAsync
@Configuration
@ConfigurationProperties("thread.pool")
public class MyAsyncConfig extends AsyncConfigurerSupport {
...
@Bean(name = "taskExecutor")
@Override
@Primary
public TaskExecutor getAsyncExecutor() {
final ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.initialize();
return executor;
}
Run Code Online (Sandbox Code Playgroud)
我自动装配的类定义了 executor 字段:
@Autowired
@Qualifier("taskExecutor")
private ThreadPoolTaskExecutor taskExecutor;
Run Code Online (Sandbox Code Playgroud)
这曾经在 springboot 2.0.2 中工作,但是当我移动到 2.1.2 版本时,我得到了
org.springframework.beans.factory.NoSuchBeanDefinitionException:没有可用的“org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor”类型的合格bean。
我解决这个问题的一种方法是在配置类中声明getAsyncExecutor()方法的返回类型为 ThreadPoolTaskExecutor. 这样做之后,它就起作用了。但我想知道为什么它不像 2.0.2 那样工作?
annotations ×1
c# ×1
eclipse ×1
eclipse-rcp ×1
editor ×1
events ×1
java ×1
markers ×1
mvvm ×1
silverlight ×1
spring ×1
spring-boot ×1