public ContestCdt(Contest contest)
 {
     c            = contest;
     CheckCommand = new IDelegateCommand((object obj) =>
     {
         Menu.Instance.Dispatcher.InvokeAsync(() =>
         {
             var cs                 = ContestsViewModel.Instance;
             cs.Status              = "checking for problems ...";
             CheckCommand.CanExec   = false;
             bool exception_accured = false;
             try
             {
                 List <Problem> probs = WebReader.ReadProblemsAll(c);
                 var col = ProblemsViewModel.Instance.Problems;
                 col.Clear();
                 for (int i = 0; i < probs.Count; ++i)
                 {
                     col.Add(new ProblemCdt(probs[i], c));
                 }
             }
             catch (Exception e)
             {
                 cs.Status = e.Message;
             }
             CheckCommand.CanExec = true;
             if (!exception_accured)
             {
                 cs.Status = "checking problems finished :)";
                 ProblemsViewModel.Instance.Status = "problems for " + c.Name;
             }
         });
     });
 }
 public ContestsViewModel()
 {
     Instance     = this;
     Contests     = new ObservableCollection <ContestCdt>();
     CheckCommand = new IDelegateCommand((obj) =>
     {
         Menu.Instance.Dispatcher.InvokeAsync(() =>
         {
             Status                 = "checking contests ...";
             CheckBtnContent        = "checking ...";
             bool exception_occured = false;
             try
             {
                 CheckCommand.CanExec = false;
                 var contests         = WebReader.ReadContestsAll("http://codeforces.com/contests");
                 var collection       = ContestsViewModel.Instance.Contests;
                 collection.Clear();
                 for (int i = 0; i < contests.Count; ++i)
                 {
                     collection.Add(new ContestCdt(contests[i]));
                 }
             }
             catch (Exception e)
             {
                 Status            = e.Message;
                 exception_occured = true;
             }
             if (!exception_occured)
             {
                 Status = "checking contests finished :)";
             }
             CheckBtnContent      = "check !";
             CheckCommand.CanExec = true;
         });
     });
 }