为什么打开和关闭窗口会加快我的应用程序速度C#WPF MVVM观察者模式
我有一个用VisualStudio2015构建的C#WPF应用程序。我正在使用MVVM和观察者模式 My Provider是一个名为“ucClientFilter1ViewModel”的用户控件,它包含两个文本框控件,用户可以在其中搜索客户端: 我不熟悉MVVM和观察者模式,所以在编写代码时,我在不同的地方加入了消息框,以帮助我跟踪它的流程。一切如期进行。然后,我删除了消息框,它仍然工作,但应用程序在最后暂停,然后您才能继续搜索 在最后放回一个消息框阻止了这种暂停。将消息框替换为仅打开和关闭的“DummyWindow”具有相同的效果,并防止在结束时暂停。这是我目前拥有的,但我不想把它留在那里 想必打开窗口会导致其他事情发生,从而停止一些冗余过程,然后阻止暂停?如果不使用此DummyWindow,我还能做些什么来防止最后的暂停 我试着在这里和Bing上搜索,但没有成功 提前谢谢 编辑: ViewModelBase为什么打开和关闭窗口会加快我的应用程序速度C#WPF MVVM观察者模式,c#,wpf,mvvm,visual-studio-2015,observer-pattern,C#,Wpf,Mvvm,Visual Studio 2015,Observer Pattern,我有一个用VisualStudio2015构建的C#WPF应用程序。我正在使用MVVM和观察者模式 My Provider是一个名为“ucClientFilter1ViewModel”的用户控件,它包含两个文本框控件,用户可以在其中搜索客户端: 我不熟悉MVVM和观察者模式,所以在编写代码时,我在不同的地方加入了消息框,以帮助我跟踪它的流程。一切如期进行。然后,我删除了消息框,它仍然工作,但应用程序在最后暂停,然后您才能继续搜索 在最后放回一个消息框阻止了这种暂停。将消息框替换为仅打开和关闭的“
namespace NSCommon
{
public abstract class ViewModelBase : INotifyPropertyChanged, IDisposable
{
protected ViewModelBase()
{
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
var e = new PropertyChangedEventArgs(propertyName);
handler(this, e);
}
}
public void Dispose()
{
OnDispose();
}
protected virtual void OnDispose()
{
}
}
}
客户端筛选器参数
namespace NSCommon
{
public class ClientFilterParameter
{
public ClientFilterParameter(ucClientFilter1ViewModel myFilter)
{
FilterLocation = myFilter.FilterLocation;
WhereSearch1 = myFilter.WhereSearch1;
WhereSearch2 = myFilter.WhereSearch2;
}
private string filterLocation;
private string whereSearch1;
private string whereSearch2;
public string FilterLocation
{
get { return filterLocation; }
set { filterLocation = value; }
}
public string WhereSearch1
{
get { return whereSearch1; }
set { whereSearch1 = value; }
}
public string WhereSearch2
{
get { return whereSearch2; }
set { whereSearch2 = value; }
}
}
}
请提供
ViewModelBase
和ClientFilterParameter
@Alireza的实现-感谢您的关注。我已经添加了ViewModelBase和ClientFilterParameter的代码。请提供ViewModelBase
和ClientFilterParameter
@Alireza的实现-感谢您查看此内容。我已经添加了ViewModelBase和ClientFilterParameter的代码。
var myDummyWindow = new dummyWindow();
myDummyWindow.Show();
myDummyWindow.Close();
namespace NSCommon
{
public abstract class ViewModelBase : INotifyPropertyChanged, IDisposable
{
protected ViewModelBase()
{
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
var e = new PropertyChangedEventArgs(propertyName);
handler(this, e);
}
}
public void Dispose()
{
OnDispose();
}
protected virtual void OnDispose()
{
}
}
}
namespace NSCommon
{
public class ClientFilterParameter
{
public ClientFilterParameter(ucClientFilter1ViewModel myFilter)
{
FilterLocation = myFilter.FilterLocation;
WhereSearch1 = myFilter.WhereSearch1;
WhereSearch2 = myFilter.WhereSearch2;
}
private string filterLocation;
private string whereSearch1;
private string whereSearch2;
public string FilterLocation
{
get { return filterLocation; }
set { filterLocation = value; }
}
public string WhereSearch1
{
get { return whereSearch1; }
set { whereSearch1 = value; }
}
public string WhereSearch2
{
get { return whereSearch2; }
set { whereSearch2 = value; }
}
}
}