Saturday, August 22, 2015

Await and Async keywords in .net 4.5

Moving to .NET 4.5, Async and Await key words are introduced for Asynchronous Programming in C#. Let's have a quick look on what these are.

Async and awit are markers which mark code positions from where control should resume after a task (thread) completes.

See the following example,

1. It goes from Main to Method() and invoked LongTask()
   in a multi threaded way.
2. And code then goes ahead "COnsole.WriteLine("New thread")"



But we want to wait LongTask() to run and then exeute  "Console.WriteLine("New thread")".

So "COnsole.WriteLine("New thread")" this should wait untill LongTask() is done.

So this is what you do with above keywords,



Now , 
after LongTask() is done, "Console.WriteLine("New thread")" line is executed means it waits till 20s and show "New thread" in the console.

Hope you have got the point. !!

reference : www.questpond.com

Wednesday, July 1, 2015

Filtering in Angular Js

This is also a sample from the reference source "AngularJs Fundamentals in 60- ish minutes"  in https://www.youtube.com/watch?v=i9MHigUZKEM

We can do filter using "filter and '|' "
Following example is to filter from group of customers using using the customer name or city name typed in the text box.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" data-ng-app ="">
<head>
    <title>Using AngularJs directives and data binding</title>
</head>
<body data-ng-init ="customers=[{name:'John Smith',city:'Phoneix'},{name:'John Doe', city:'New York'},{name:'John Doe', city:'San Francisco'}]">
    Name:
    <br />
    <input type="text" data-ng-model ="name" /> {{name}}
    <br/>
    <ul>
        <li data-ng-repeat ="cust in customers | filter: name">{{cust.name}} - {{cust.city}}</li>
    </ul>

    <script src="Scripts/angular.min.js"></script>
</body>
</html>


Monday, June 29, 2015

AngularJs

I would like to open up a basic step into Angular Js in this post.

First question came up into my mind when I started to learn is "Why AngularJs?"
So the answer is here. Read these posts which are very helpful for the above question

http://jeffwhelpley.com/angularjs/

http://stackoverflow.com/questions/14994391/thinking-in-angularjs-if-i-have-a-jquery-background/15012542#15012542

This is a sample for "Using directives and data binding" from the reference source "AngularJs Fundamentals in 60- ish minutes"  in https://www.youtube.com/watch?v=i9MHigUZKEM


I have created VS 2013, ASP.NET project and added the following html page with angular.min.js file inside the script folder. You can download the angular.min.js file in https://angularjs.org/


<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" ng-app ="">
<head>
    <title>Using AngularJs directives and data binding</title>
</head>
<body>
    Name:
    <br />
    <input type="text" ng-model ="name" /> {{name}}
    <script src="Scripts/angular.min.js"></script>
</body>
</html>

Try it !!

Monday, April 20, 2015

Panel control in Windows Forms

Some important properties of panel control have been highlighted here.

1. Border Style
















2. Border Style

 



Since I have set the AutoScroll property to True I can scroll to see the invisible controls out side the panel border.