User:Hcaoduc/sandbox

Introduction
Microsoft Visual C# is Microsoft's implementation of the C# specification, included in the Microsoft Visual Studio suite of products. It is based on the ECMA/ISO specification of the C# language C# language, which Microsoft also created. While multiple implementations of the specification exist, Visual C# is by far the one most commonly used. In most contexts, an unqualified reference to "C#" is taken to mean "Visual C#."[citation needed]

The term Visual denotes a brand-name relationship with other Microsoft programming languages such as Visual Basic, Visual FoxPro, Visual J# and Visual C++. All of these products are packaged with a graphical IDE and support rapid application development of Windows-based applications.

Visual C# is currently used in development of Windows and Xbox Live games via Microsoft XNA, which allows game developers to create and share their games with other gamers. Visual C# is also heavily used by ASP.NET web sites and standalone applications based on the .NET Framework. Note: As of October 2012 Microsoft has ended support and future releases of XNA.

Microsoft Visual C# IDE
When you start Visual C#, Start Page is displayed. Start Page has two columns; the left column holds Start and Recent sections. These sections contain options for developers to create a new application or work with an existing one, respectively.

Visual C# places Get Started and Latest News tabs in the left column so developers can find useful information about application development, resources, and a tutorial. It is necessary for the user to have an internet connection to access the latest news. . 	       Menubar provides functions to developers for coding, maintaining and executing their programs. Menubar contains:  	DEBUG: used for compiling, debugging and running apps.  	TEAM: contains functions to connect to Team Foundation Server. 	FORMAT: contains commands to arrange and modify Form’s controls. 	TOOLS: contains commands to customize the IDE. . 

Visual C# syntax
Visual C# is an object oriented programming language (OOP); its syntax is identical to C++ or Java. The main parts of the syntax are variables. It uses operators to change their values, to create classes, methods and pass data to these methods. .

Controls
Visual C# uses System.Windows.Forms.Control class to create most controls for developers. These controls are inherited as shown in the figure. The most common controls are Label, Textbox, Button, and Checkbox... .

Properties
Properties describe shape, size and other characteristics of control. Controls inherit or override properties, which defined in the System.Windows.Forms.Control class to create their own properties. The following table lists some common properties of Visual C# controls. .

Events
Visual C# provides Windows.Forms.Controls class to create Events. These Events will be activated when there is an action. For example, when a user click a button will raise a Click_Event of this button. Developers are expected to write a method to handle these actions. Their code blocks are called Event Handlers. .  	        There are three options to work with Event Handler. The simplest way is to double-click control when you want to add Event Handler. Visual C# will display the default Event Handler of this control. If developers need other Event, they have two ways to find it. They can use the Properties window located on the right side of Visual C# IDE. It lists all Events of the control and developers can pick the desired Event. The quickest way is if the developer types a definition of this Event Handler directly into the code editor, but this requires a lot of experience. .

Write a Windows Application
When creating a Windows application, developers first design user interface by using controls which is available in the Toolbox window. Programmers add an instance of a control into a form by double-clicking on this control template. Microsoft Visual C# provides most controls need to build a user interface, developers can also buy a custom control from third party software companies. After the user interface is created, the next step is adding Event Handler to these controls. Click on a button, Visual C# will generate a method as follows:. private void buttonName_Click(object sender, EventArgs e) { //Place your code here; }  The code block defines a method called "buttonName_Click", as you can see; names of the button and Event are combined to form the name of method. This method will be executed when user click on the button. In this case, there are two parameters. The object sender parameter indicates a control which user clicks on, and the eventArgs e provides information of what exactly happened with control. .

Deploying Windows Applications with CLICKONCE
Visual C# provides ClickOnce for developers to help them to distribute their applications more easily. When users want to install an application, all they need to do is click on a link in the installation Webpage. After the installation is finished, users can be offline, there no need to access to the Webpage if they do not want to update their software. The application is available on the Start menu in client system; it can be uninstalled with Add/Remove program dialog. ClickOnce uses manifest files for describing an application, permission required, configuration information and update policies. .

Building Professional Windows 8 Applications with Visual C#
Microsoft designed Windows 8 with the intent to provide a platform to the next generation of mobile devices. Users install Windows 8 operating system on their laptop can feel like they are using a tablet or smartphone. Users can input data into their system by using a touch sensitive screen and they can know their system location or orientation if the device hardware supports appropriate sensors. Developers can upload applications to Windows Store to share with other people. For this reason, those applications are known as Windows Store apps. .

Multitasking
Developers use multitasking approach while developing an application when they want to achieve: Responsiveness: If programmers divided an application into small threads and assigned a short time period to each thread, users can feel that the application can run multi tasks at the same time. However, this is not true multitasking because these threads share the computing time of the processor. The advantage will be lost if there was a thread which dominated time consuming. In the past, it was not easy to implement true multitasking in an application. Now, Windows 8 with Windows Runtime provides many API functions to address this issue. . 	       Scalability: Scalability can be increased if an application handles computing resource better. Developers identify which parts of an application can be processed in parallel manner and make an executing schedule for them. The MPI (Message Passing Interface) protocol provides mechanism so that parallel tasks can communicate to each other by sending a message. . 	       In a multiprocessors system or a system with multicore processor, an application can execute a number of concurrent tasks, which will not exceed the number of processors (or cores). If an application always uses all of these processors, it will be finished very quickly. Programmers have to answer the following questions then they want to put their applications in multitasking mode:.  How to identify which parts are parallel How to ensure that number of concurrent task at a time will not exceed the number of processors in the system</li> <li>Suppose that there is a task waiting for an I/O operation, how to recognize this task and indicate the application to switch to another task</li> <li>Which sign show that a task is completed </li> </ul> Developers use Task class and System.Threading.Tasks namespace to address this issue. A concurrent task is an instance of Task class, it is used to execute inside code block. For example, to run a job named doThisWork, a Task object is defined as follows:. <i>Task task = new Task(doThisWork); private void doThisWork { // The task runs this code when it is started ...} </i>and execute this Task by Start method: <i> Task task = new Task(...); task.Start;	 </i>

Improving Response Time by Performing Asynchronous Operations
User interface also is a concurrent task, and users want to interact with the application even when this application is doing another complicated task. The answer to this problem is executing all the tasks in asynchronous manner. Visual C# provides a platform for developers to overcome the difficulty of defining asynchronous methods. . 	       An asynchronous method is the method in executing mode will not block current thread. It returns control permission to calling environment as soon as possible. Programmers use await and async keywords to declare a synchronous method, for example: <i> private async void slowMethod { 	        await doFirstLongRunningOperation; await doSecondLongRunningOperation; await doThirdLongRunningOperation; messages.Text = "Processing Complete"; }</i>.

Windows Store App
Windows Store apps usually consume the whole screen of a device so they do not have borders, menu or popup dialogs. In other word, they are chromeless. Developers believe that these components distract users, so Windows Store apps are designed without these traditional elements to help users focus on their task. . 	       When developers create a new Windows Store app, Visual C# helps them to package and upload the application to Windows Store so that other people can access this application. Applications must pass all the security test of Microsoft so that it can reside in Windows Store. Developers can make their applications free or they can charge for their development time and effort. .