/// <summary> /// 构建对象。 /// </summary> /// <param name="sourceFile">功能块数据来源对应的文件。</param> /// <param name="pouAttributes">数据来源中的功能块的特性。</param> public ViCPUPouSource(IViPouSourceCPU cpu, ViPouAttributes pouAttributes) : base(cpu.ProjectFile, pouAttributes) { this.cpu = cpu; cpu.CPUInfoChanged += cpu_CPUInfoChanged; }
/// <summary> /// 释放与其它对象之间的弱引用。 /// </summary> public override void Dispose() { if (this.cpu != null) { this.cpu.CPUInfoChanged -= cpu_CPUInfoChanged; this.cpu = null; } base.Dispose(); }
void cpu_CPUInfoChanged(object sender, ViPouSourceCPU.CPUInfoChangedType changedType) { // 强制刷新 CPU 信息 this.CPU = this.cpu; }