While developing a WPF
application with a WCF
service I realized that sometimes the application is really slow. For example, when I call a method from the WCF
service which returns a list, it takes too much time to execute this. Here is some code:
MVVM:
private ObservableCollection<tblStock> _Stocks;
public ObservableCollection<tblStock> Stocks
{
get
{
return _Stocks;
}
set
{
_Stocks = value;
OnPropertyChanged("Stocks");
}
}
private ObservableCollection<tblClient> _Clients;
public ObservableCollection<tblClient> Clients
{
get
{
return _Clients;
}
set
{
_Clients = value;
OnPropertyChanged("Clients");
}
}
When I open a window there are two comboboxes bound to those properties. Those properties get set in the constructor of my view model class like so:
Clients = new ObservableCollection<tblClient>(wcf.GetClients());
Stocks = new ObservableCollection<tblStock>(wcf.GetStocks());
It takes about 7 - 10 seconds sometimes to load these comboboxes when the window opens. I don't understand why so much time is needed when list counts are really small: 2 and 8 items. Here are the methods on wcf service:
List<tblClient> IService.GetClients()
{
context = new PanErpLiteEntities();
List<tblClient> cntnt = (from c in context.tblClients select c).ToList();
return cntnt;
}
So my actual question is: what are the possible reasons of slowing down my application? I posted this question becouse it was to hard for me to find the answer on google when there are millions of reasons causing the application to work slow, so I'm here for the tips actually. I hope I made myself clear enough.