private void BrowseBtn_Click(object sender, RoutedEventArgs e) //multi tasking required { if (CurrentRegulation.PermanentRecord == true) { ErrorHandler.NotifyUser("سند به ثبت نهایی رسیده است "); return; } if (VersionTxt.Text.Trim() == "") { ErrorHandler.ShowErrorMessage("ابتدا ورژن فایل را وارد کنید"); return; } string fileLocation = OpenFileHandler.OpenFileToUpload(); if (fileLocation == null) { ErrorHandler.NotifyUser("فایلی انتخاب نشد"); return; } else { try { layoutRoot.Children.Add(busy); int a = CurrentRegulation.RegulationId; string text = VersionTxt.Text; Task.Factory.StartNew(delegate { byte[] fileContent = OpenFileHandler.GetFileFromLocation(fileLocation); string fileName = System.IO.Path.GetFileName(fileLocation); int fileId = DataManagement.AddRegulationFile(fileName, fileContent, text, a); fileContent = null; GC.Collect(); ErrorHandler.NotifyUser("فایل با موفقیت ثبت شد."); }).ContinueWith(delegate { Grid.ItemsSource = DataManagement.RetrieveRegulationFile(CurrentRegulation.RegulationId); layoutRoot.Children.Remove(busy); }, TaskScheduler.FromCurrentSynchronizationContext()); } catch { ErrorHandler.NotifyUser("ثبت فایل موفقیت آمیز نبود"); } } }