background preloader


Facebook Twitter

Asynchronous Programming with Async and Await (C# and Visual Basic) You can avoid performance bottlenecks and enhance the overall responsiveness of your application by using asynchronous programming.

Asynchronous Programming with Async and Await (C# and Visual Basic)

However, traditional techniques for writing asynchronous applications can be complicated, making them difficult to write, debug, and maintain. Visual Studio 2012 introduces a simplified approach, async programming, that leverages asynchronous support in the .NET Framework 4.5 and the Windows Runtime. The compiler does the difficult work that the developer used to do, and your application retains a logical structure that resembles synchronous code. As a result, you get all the advantages of asynchronous programming with a fraction of the effort.

This topic provides an overview of when and how to use async programming and includes links to support topics that contain details and examples. Asynchrony is essential for activities that are potentially blocking, such as when your application accesses the web. Task Parallelism (Task Parallel Library) When you create a task, you give it a user delegate that encapsulates the code that the task will execute.

Task Parallelism (Task Parallel Library)

The delegate can be expressed as a named delegate, an anonymous method, or a lambda expression. Lambda expressions can contain a call to a named method, as shown in the following example. Note that the example includes a call to the Task.Wait method to ensure that the task completes execution before the console mode application ends. Parallel Programming in the .NET Framework. Parallel LINQ (PLINQ) Garbage Collector Basics and Performance Hints. Rico Mariani Microsoft Corporation April 2003 Summary: The .NET garbage collector provides a high-speed allocation service with good use of memory and no long-term fragmentation problems.

Garbage Collector Basics and Performance Hints

This article explains how garbage collectors work, then goes on to discuss some of the performance problems that might be encountered in a garbage-collected environment. (10 printed pages) Applies to: Microsoft® .NET Framework Contents Introduction Simplified Model Collecting the Garbage Performance Finalization Conclusion Introduction In order to understand how to make good use of the garbage collector and what performance problems you might run into when running in a garbage-collected environment, it's important to understand the basics of how garbage collectors work and how those inner workings affect running programs.

Simplified Model For explanatory purposes, consider the following simplified model of the managed heap. Figure 1. The rules for this simplified model are as follows: Collecting the Garbage. LINQ Tutorials - Get Started.


Code First Entity. Serial Comms in C# for Beginners. Download source Introduction Serial Communication between PCs is always seen as the starting point.

Serial Comms in C# for Beginners

My first piece of serial comms code was a University assignment getting two PC’s, then three, then… you get the idea talking on (what I now know to be) an RS422 with its pair of cables using Borland's Turbo C++ for DOS. Time passed I graduated (somehow!) And I got to be a Design Engineer in the ‘real’ world. Background RS-232 is the best know method of PC Communications, the characteristics of RS232 is a logic 1 (true) is can range from -3v to -25v a logic 0 (false) +3v to +25v. VB6 used MSComm32.ocx; this was a 32 bit version of MSComm16.ocx both of these components worked fairly well. Serial Ports have now adopted (and in some cases dropped) the 9 way D-type, though I have come across older kit (notably high precision colorimeter cameras from Samsung) use the older 25 D-type. Hide Copy Code Using the code Setting Up. Serial Port Communication Tutorial With C# Examples - In today’s programming tutorial, I am going to describe some basics about how we can perform serial port communication from our C#.NET applications.

Serial Port Communication Tutorial With C# Examples -

Serial communications can be done via either direct to physical serial port connected to the computer or via a USB to serial converter interface. If the device do require a serial port and your computer don’t have any, you can make use of such converters easily. This type of communication aren’t as much easy as other similar tasks such as working with logic drive on computer via c# and need use of specific kind of communication protocol. One interesting thing that you might need to remember that, when the physical serial port are being used, it doesn’t have any PID or VID.

Retrieve List Serial Ports: OK, lets first see whether we can detect the serial ports from within our application. And it is enough for further processing. .NET can understand where to communicate via the port name in string like “COM1″, “COM2″ etc. Support Jesse Dietrichson creating Programming Tutorials. Programming is what I want to do with my life.

Support Jesse Dietrichson creating Programming Tutorials

I began programming from a very young age, and once I started I couldn't stop. Most of what I know has been self taught. I've spent countless hours over the years, reading every programming book I could get my hands on. I specialize in C#, C++ and Java, and I am always trying to learn more. I am continuing my programming career as a computer science major at Farmingdale State College. I have always loved helping and teaching other people how to program and my goal in life is to become a professor; this is just one small step to reach my ultimate goal.

That being said, I am just like any other college student, who is looking to make some money on the side. *** Note to all Patrons*** Most of my videos listed on Patreon are accessible for free on YouTube. Jesse Dietrichson. Threading in C# - Free E-book. Threading in C# Joseph Albahari Last updated: 2011-4-27 Translations: Chinese | Czech | Persian | Russian | Japanese Download PDF Part 1: Getting Started C# supports parallel execution of code through multithreading.

Threading in C# - Free E-book

A C# client program (Console, WPF, or Windows Forms) starts in a single thread created automatically by the CLR and operating system (the “main” thread), and is made multithreaded by creating additional threads. All examples assume the following namespaces are imported: using System; using System.Threading; class ThreadTest{ static void Main() { Thread t = new Thread (WriteY); t.Start(); for (int i = 0; i < 1000; i++) Console.Write ("x"); } static void WriteY() { for (int i = 0; i < 1000; i++) Console.Write ("y"); }} The main thread creates a new thread t on which it runs a method that repeatedly prints the character “y”.

Once started, a thread’s IsAlive property returns true, until the point where the thread ends. Done.