Tag Archives: C# tutorial video

C# 2012: Anatomy of an Async Method

There are two new keywords added to C# for asynchronous programming: async and await. The async keyword is a modifier for methods, delegates, and lambdas to indicate to the C# compiler that a method might contain async code. It also allows other code to call this method asynchronously. 

If a method doesn’t contain async code, it executes synchronously, but you will receive a warning message from the C# compiler. To run code asynchronously, use the await modifier when executing a method, anonymous method, or lambda. Here’s an example of using async and await keywords to implement an async method:

The async modifier indicates that StartAsync can contain async code. The await modifier calls the DoNetworkCommunicationsAsync method and waits for it to complete. In other words, it awaits the method.

Notice the suffix to the StartAsync method is Async. You aren’t required to add the Async suffix to the method name, but it’s a convention that Microsoft recommends and most developers follow in practice. Another tip on naming conventions refers to methods in earlier versions of .NET that implement EAP and already have the Async suffix—you would name them with the TaskAsync suffix.

To make the example simpler, the return type in the previous example is void, but async methods do have return types other than void. For now, let’s defer discussion of the return type until later, which is an important subject of its own.

The previous example doesn’t have any parameters by design in order to keep it simple. However, async methods can have parameters, but none of the parameters can be ref or out.

As in APM and EAP, as soon as the code calls an async method, with the await modifier, control returns to the caller while the method executes asynchronously. Expanding on the previous method, the following code demonstrates a basic example of how async methods work:

Let’s look at what this code shows in terms of control or what is running when. The specific threading model is defined separately for each .NET technology by a type derived from SynchronizationContext, but this is beyond the scope of this course.

The Main method calls the StartAsync method. Because StartAsync is modified as async, the code will run synchronously until it encounters a call to an async method with the await modifier. As soon as the code calls the method with await, control returns to the calling code Main. So you have two methods running at the same time—Main and StartAsync.

StartAsync continues by calling the DoNetworkCommunicationsAsync method. However, the await modifier makes StartAsync wait until DoNetworkCommunicationsAsync completes. When DoNetworkCommunicationsAsync completes, StartAsync ends. Control was already returned to Main when it encountered the await call to DoNetworkCommunicationsAsync, so StartAsync does not return at the end of the method, it just stops running.

That means that inside of StartAsync, all the code above the awaited method will run synchronously. At the same time, the async method runs. When
DoNetworkCommunicationsAsync completes, control returns to StartAsync and any code following StartAsync executes.


JoeMayoThis post is an excerpt from the online courseware for our C# 2012: Asynchronous Programming course written by expert Joe Mayo.

Joe Mayo is an author, independent consultant, and instructor specializing in Microsoft .NET and Windows 8 technology. He has several years of software development experience and has worked with .NET since July 2000.

Using Reflection

Reflection gives you the ability to inspect the code of a .NET application and execute that code dynamically. Various tools, such as VS 2012 Web Services and unit testing use reflection to perform actions based on the code you’ve written. When building a Web Service, VS 2012 uses reflection to inspect the attributes applied to classes and then read the method names, parameters, and return types of those methods to build an XML contract for clients to consume.The Unit Test runner uses reflection to find classes that contain tests and execute the methods decorated with test attributes.

Getting Type and TypeInfo

The first step in using reflection is to obtain a Type type or a TypeInfo type. A type is a class, struct, interface, or delegate that you write in order to inspect and learn more about the type. TheType andTypeInfo types let you furtherdelve into the internals of a type, using reflection, to learn about the membersof a type. The Type type has been part of .NET since v1.0. Microsoft introduced the TypInfo type in .NET v4.5, which also supports Windows 8
applications. The difference between Type and TypeInfo in .NET 4.5 is that Type provides reference support and TypeInfo is intended for execution.

If you already have an instance of an object, you can get its Type through the System.Object’s GetType method, like this:

In this example, the code has an instance of Program, prog, making it possible to call GetType to obtain the Type object. TheType object has manymethods for inspecting the type and it contains assembly information. This example prints the Name property, which is Program

Another way to obtain a Type is via the typeof operator. This is a C# operatorfrom basic C# syntax, but now you understand its true purpose and how to use it. Here’s an example:

You give the name of the type to the typeof operator and it returns a Type instance for that type. This example uses the AssemblyQualifiedName, whichgives the fully qualified name of the assembly, as follows:

With a Type, you can get a TypeInfo. Here’s an example:

The example above shows that you must first have a Type, which is testType in this case. With that Type , you can call GetTypeInfo to obtain a TypeInfo .

JoeMayoThis post is an excerpt from the online courseware for our C# 2012: Attributes, Reflections and Dynamic
course written by expert Joe Mayo.

Joe Mayo is an author, independent consultant, and instructor specializing in Microsoft .NET and Windows 8 technology. He has several years of software development experience and has worked with .NET since July 2000.

Need Reasons Why C# is the Best Language for Mobile Apps Development?

c video course

When it comes to honing your programming and development skills, it is worthwhile to consider the old adage “follow the money.” After all, no one wants to become an expert in a programming language that will be extinct in five years. At the same time, programmers should pay attention to heavily-hyped languages, as they could be their meal ticket towards a prosperous and exciting career.

Of course, we don’t use the word “hyped” lightly. Many languages have been billed as the “next big thing” only to quickly fizzle. That’s why we really like this article, which provides eight concrete and convincing reasons why C# is the best language for mobile development. No hype, just facts.

Ultimately, the language has many benefits that make it conducive towards long-term development for business purposes. For example, it’s very reliable and allows programmers to detect and isolate bugs quickly. It boasts advanced runtime and powerful features like object-oriented programming and encapsulation.

And perhaps most importantly, it’s easy to adopt, especially for developers well-versed in object-oriented programming. So what are you waiting for? Sign up for our C# tutorial video today.

Thousands of developers worldwide use LearnNowOnline to gain the technical skills they need to succeed on the job and advance their career.

More Evidence that C# is Poised to Become the Mobile Development Language of Choice

c video course

If you need further proof that C# is poised to become the mobile application programming language of the future, ZDNet is reporting that Xamarin, the Boston-based software company, will now start allowing iOS coders to use Microsoft’s Visual Studio.

This is important news because according to Xamarin, it is the first time any software company has enabled developers to build iOS applications using Visual Studio. That’s because the company – along with other development experts – believe that C# is the optimal language for mobile development.

Developers looking for a job or to switch careers should take note. After all, the future of the Internet is increasingly mobile, and C# is poised to take center stage. Just take a cursory look at any job board and you’ll see disproportionate amount of C# openings. Fortunately, our C# tutorial video library enables you to learn the language in the comfort of your home and at your own pace.

The mobile future is coming, whether you like it or not. Make sure you’re ready.



Thousands of developers worldwide use LearnNowOnline to gain the technical skills they need to succeed on the job and advance their career.

Programmers & Developers Take Note: Yahoo to End All Telecommuting Arrangements by June ’13

The programming and developing world is buzzing over news that Yahoo will significantly restrict work-from-home options for its employees. In case you missed it, Yahoo’s HR department recently sent a memo to all telecommuting employees telling them that come June 2013, they needed to return to work in the office.

Yahoo’s made this decision because they felt that employee interaction was critical to their company’s success. They argued that good ideas are generated in the office, where employees informally interact in the cafeteria, the kitchen, or around cubicles. That said, the news was greeted with derision in Silicon Valley, particularly other technology companies, who argued that the freewheeling, information culture should allow for telecommuting as well as other perks like free food, game rooms, and complementary bus service.

Ultimately, these kinds of perks make a difference for job-hunters. So if you’re an IT worker looking to expand your skill set, first we recommend any of our online options, such as C# tutorial video. And once you become an expert in this field, you’ll have luxury of shopping around for jobs. And if you really want to telecommute, you can cross Yahoo off your list.

Facebook is Sending Its Employees to Boot Camp….Coding Boot Camp!

Screen Shot 2013-03-07 at 1.03.29 PMFor those of you keeping track of the big trends in the IT and online marketing world, you’ll know that mobile computing is poised to be “the” big issue for 2013 and beyond. After all, more and more users are surfing the Web from mobile devices, and it’s sending all sorts of shockwaves throughout Silicon Valley.

For example, companies like Dell, which specialize in manufacturing PCs (remember them?) are in big trouble. The same with Intel, whose business model is predicated on selling chips for mainframe and workstations. And then there’s Google, who has restructured their AdWords program so that more of their customers place ads on mobile devices, where they pay-per-click rates for Google are higher.

And now Facebook is joining the party. According to this article, the company is sending employees – even non-IT employees – to “coding boot camp.” And it’s not just plain old coding – it’s mobile development that they’re focusing on. After all, the company’s mantra nowadays is “mobile first.”

You can see a trend developing here.

The bottom line: if you’re an IT professional looking to make yourself marketable, mobile development is where it’s at. And with C# being hailed as mobile’s best hope, our C# tutorial video is a great place to start!




Creating a Learning Culture



The better informed the people who work in your business are, the better they will be able to do their jobs effectively and efficiently. This is true in almost all work environments, but is especially true when it comes to IT departments, who are constantly having to master and learn new technologies before they have totally figured out an older program or system they are working with. Due to the speed at which technology moves these days, those within IT departments often find themselves overwhelmed by the amount of new information they have to digest in a short amount of time. This can often slow down the department and, in many cases, the business as a whole.

One great way to keep this from happening is to create a learning culture, one in which the employees of the IT department are interested and used to learning new programs and systems on a regular basis, as part of their jobs. Regular tutorial sessions may be one of the best ways to accomplish this. Video tutorials are incredibly effective, as employees can watch these on their own time or as a group. These can range from Visual Studio 2010 tutorial videos to video tutorials for C#. Courses can also be offered to employees free of charge as part of work requirements! In fact, tutorials are offered for just about every IT department program out there, so theoretically a business could create an easily accessible library of this information for their employees to access on their own, whenever they need it.

The information you make available and the more employees are encouraged and even paid to learn more about their trade, the stronger the learning culture will be at your company. When this is the case, everyone will be educated for just about any challenge work throws at them and will be easily able to overcome it.

Thumbnail for 637