While working with UI based applications, one of the most important thing that you need to keep in mind is Thread Affinity. It ensures that every control needs to be created in the UI Thread to be ported in the UI and each of them could only be accessed through UI Thread only. Earlier, the Windows Forms application… Read More »
Similar to Lazy, ThreadLocal creates object local to one thread. So each individual thread will have its own Lazy initializer object and hence will create the object multiple times once for each thread. In .NET 3.5 or before, you can create objects that are local to one thread using ThreadStatic attribute. But sometimes ThreadStatic fails to create a… Read More »
Barrier is a new type introduced in .NET 4.0. It allows the user to define the synchronization primitives and lets your Threads to run code simultaneously in predefined phases. A Barrier defines a phases in such a way that the Thread executing some set of code reaches a certain point where it is stopped and sent to wait… Read More »
Multi-Threading is not new to the programming world. We use multi-threading in our application to enhance the throughput and responsiveness of the application, but with concurrent access of certain resources, the application is prone to deadlocks and Race conditions. The post will guide you through how to avoid such kind of scenarios.
Yesterday, I have posted one tip which discusses how you could use ReaderWriterLock to implement shared locking on items that does require concurrent access. Today I will use SpinLock to do the same. SpinLock like Monitor spins a number of CPU cycles when it tries to acquire a lock. Monitor on the other hand Spins some CPU Cycle… Read More »
If you are looking for Multi-Threaded application, you must have already tried our very old lock statement (synclock in VB.NET). The lock statement is the most common practice to make certain block of code Thread safe or in other words, it blocks all other Thread from entering the block which one thread is actually executing. The lock statement… Read More »
In any programming language that supports multi-tasking (which is supported by most of the modern languages) Threads are the most important part (tool). We use threads to run something which does not need user interaction and which runs in parallel with the normal operations by the user. In C#, a special class is provided which creates a new… Read More »
In this tips I am going to discuss how you can get list of all WPF elements which are type of Controls and can be accessible publicly. To achieve this I have used reflection to hook the .NET API and get the list of Assembly elements which are types of Controls.