My main MainWindow.xaml.cs has a lot of Task variables and as a consequence a lot of
private void ContentManagerUpdateUI()
{
// ... UI update work here ...
}
private void StartContentManager()
{
contentManager = Task.Factory.StartNew(() => { ContentManagerJob(); }, TaskCreationOptions.LongRunning);
contentManager.ContinueWith((t) => { ContentManagerUpdateUI(); }, TaskScheduler.FromCurrentSynchronizationContext());
}
private void ContentManagerJob()
{
...
}
My question is if there is any best way to take these methods away from the main file?
I just want to make code more logical and cleaner.
Thank you!
==================================
P.S. Hey… I use #region … #endregion 🙂 But I guess it must be implemented with some static classes or something that lives outside of MainWindow.xaml.cs…
Also I don’t think about MVVM because this application doesn’t have any user’s input at all.
May be I have to redefine my question… I mean what is the best way to arrange multiple variables and methods of Task class of MS TPL.
I am not quite sure whether i understood your question but if you want to logically structure your code without altering its meaning try to think about partial classes.
The .cs code-behind file of a XAML file is declared as partial by default so you can add as much additional partial classes as you want. Of course you have to meet the restrictions for using partial class e.g. all classes that are declared as partial have to be in the same namespace but you find plenty of information on that over the internet.
Hope this helps 🙂