Skip to main content

Posts

Controlling Degree of Concurrent Execution in Parallel Loops

Having multi-core machine, one can get the benefit of Parallelism for long-running and blocking tasks. I hope most of you might have used Parallel. For, Parallel. Foreach and TPL several times. Generally parallelism is used to get the benefits of all the available cores on the machine that commonly leads to the shortest execution time for any task. Did you ever thought about what can be the possible demerits of using all the available cores for just a single application? Is it really required to use all the available cores of your machine for a single application? Can't we use only a few of the cores? Is there any way to restrict these parallel loops in terms of cores? The answer of all the preceding questions is YES . But why should we bother about how many cores are participating in execution? Well, there can be several reasons behind this.  The foremost reason  that I feel is, when a single time consuming application/task is running on all the available cores utilizing

New features of Windows Phone 8.1

2 nd April 2014, during the //BUILD 2014 conference Microsoft officially showcased the set of new features which will be coming as part of Windows   Phone 8.1.  In my this post, I am touching those features. 1) Cortana - new personal assistant:  Cortana is voice-based virtual assistant provided by Microsoft. It is similar to Apple’s ‘Siri’ and is powered by Bing. It can do everything that one would expect from any virtual assistant. Cortana offers advanced settings and preferences with more than the default voice commands. One can talk with her and can also give her instructions to perform any operations behalf on you. Cortana is fully based on your search queries, she learns your interests, she learns about the most important people in your life. For example, you can instruct her “Cortana, call Shweta on Skype” and it will open Skype to call the person. Isn’t it interesting ? You can also use Cortana to set reminders by saying “Cortana, remind me to go to parlor when I am in

Cursor Position on Enter key

Recently, one of my followers requested for a code snippet to implement the ENTER key press. The requirement was to move the cursor on the next WPF UI element, whenever the ENTER key is pressed. Implementation of the above requirement is straight forward, if one has the knowledge of InputBindings and Command. Using these two, MoveFocus method of currently focused element, can be called, as shown in the mentioned below code snippet: Hope it will help you.

Restoring Nuget packages in less annoying way

Hope most of you are aware of Nuget packages. It is a way to get 3rd party libraries into your project. Nuget also makes developer's life easier by checking for updates for all the available libraries. Apart from this Nuget also provides package restoration option, which is disabled by default. Another annoying thing about restoration is, it is very very slow. So, it means that until your restoration is complete, you can not do anything. What is the solution or workaround of this slow restoration of Nuget package ? Well, one workaround can be instead of restoring packages from Visual Studio, why can't we do it outside of Visual Studio. Interesting, isn't it ??? A Very simple and straight forward command to do this is: NuGet.exe restore [SolutionFile] –PackagesDirectory [PackagesDirectory]

Congratulations! You have received MVP award

Hey folks, I have something very exciting to share with you all. Today morning, I received a mail stating " Congratulations!  You have received MVP award” . At first I didn’t believed my eyes, but after reading a mail, finally I got a feel that I really won. Actually it was surprised for me too !!! I’m really proud that someone noticed my technical skills and what I do for community. Whenever I meet or look at other MVPs, I always think, “Wow, these guys are brilliant! Simply awesome…I wish I could…” But finally it happened. I’m honored to be a part of the C# community. It’s a privilege. MVP: MVP is an annual award given by C# corner to its community leaders who actively share their technical skills and excellent knowledge.  This award recognizes exceptional technical community leaders who have deep understanding on some technology and how they can contribute to communities so that people around them can make the most out of them. Every day, around the world, MVP A

Customizing debugging session - Part II

Continuing to my previous article on 'Customizing debugging session' , we can further control on how properties and fields appear in our debugger window. Based on our debugging requirement, we can show and hide properties in our debugging session using one of the useful attribute named DebuggerBrowsableAttribute . Let’s go ahead and see debug window for one of the code snippet: In above image you will notice that by default list of Awards is not in expanded form. In order to view the values of awards, one needs to expand that forcibly either by hovering the mouse or by click on the plus symbol, which will result in below screenshot: How to hide unwanted properties during debugging session? What if a developer is not interested in viewing employee’s branch? Well, that unwanted property can be made hidden by using DebuggerBrowsableState as Never as shown below: Now let’s run the code and check, whether it is h

Customizing debugging session - Part I

I hope, being a developer everyone needs to debug their code at least once a day even if it is a very small snippet. Frankly speaking, sometimes it becomes very frustrating when we are looking for a value of particular property or let’s say very few properties of a huge object and it gets TIMEOUT. Uhhh !!! This time, we feel like there should be some easy way to navigate to that particular property instead of going to the object and clicking on plus symbol to reach the required property. Well, let’s understand it via code: Aim: I have an Employee class with two members as EmployeeName and BranchName. I want to know the name and branch of an Employee during my debugging session. So, I start debugging and lend up on below screen: Now in order to view the required details, I need to expand the employee object as shown in below screenshot: Now first question is, is there any way to display customized message in debugger window?  Answer would