When you have a simple for each loop in your code, sometimes it's possible to make the loop faster by using Tasks. The idea is to create a task for every item in the loop. You start the task when you go over it. After the loop finishes you will wait for all the tasks to finish and you are good to go..
This is an example of an optimized loop:
// Get the collection
var dataCollection = GetCollection();
// Create a list to keep track all tasks
var tasks = new List<Task>();
// Check all entries
foreach (var entry in data Collection)
// Create a task and execute it immediately
var t =Task.Run(() =>
// Do your thing here
// Add the task to keep track of it
// Wait for all tasks to complete
When you have a lot of items in your collection the benefits will increase.
When you are unit testing in ASP.NET MVC problems will occur when you don't use the FixtureSetup method. When you run 'all tests' and only the first test will pass, you will have to use a base class.
The error looks like:
'A route named 'XXXX' is already in the route collection. Route names must be unique.'
For example you can use this empty class and have your test class inheriting this base class:
public class BaseFixture
public void FixtureSetup()
public void FixtureTearDown()
public void SetupTest()
public void TeardownTest()
When you bind the DataContext of an UserControl XAML to the code part of the file, you can use this method:
If you want to bind to a property of another element, this is the way to go:
2. In SourceTree: Clone Repository.
3. Fill out the data:
Change the items between the brackets in the correct ones.
4. Click on Clone
This should be all to get the sources locally.
How do we get this menu item on the toolbar.
And I want it Here:
Right click on the toolbar and click 'customize'. The customize window will open. Click on the 'Commands' tab and select the Toolbar 'Standard'.
Right now you click on 'Add command' and the following window will open.
Click on 'Edit' in the left pane, and Find 'Outline Collapse To Definitions' in the right pane.
Then hit 'Ok'
Move the command to the correct position and hit 'Close' and you're done.