CS411 Short Notes
CS411 Short Notes
com
1). Commands are a more robust and loosely coupled version of:
Events
5). For cut, copy and paste we can define and implement three classes mplementing
icommand
www.vuanswer.com
www.vuanswer.com
11) TextBox is an example of Control with builtin command binding that responds to
ctrl-z etc.
www.vuanswer.com
www.vuanswer.com
Select Stop
www.vuanswer.com
www.vuanswer.com
1).WPF Window is a:
win32 window
www.vuanswer.com
www.vuanswer.com
10). Window.show() is used to instantiate (Read-only) window.
11). Properties Dictionary is a simple Dictionary used to share things among different
windows.
18). Modal Dialog are such windows that are necessary to terminate explicitly in order
to interact with main window.
19). In modeless Window we can work in parallel with main window just like using
Tools window in Photoshop.
20).Common Dialogs are actually provided by win32 and are part of Modal dialog.
21). Custom Dialogs are user-defined.
www.vuanswer.com
www.vuanswer.com
Windows Installer
www.vuanswer.com
www.vuanswer.com
8). Page does everything that windows does except OnClosed and OnClosing.
10). A page can interact with its Navigation Container by using NavigationService
Class.
www.vuanswer.com
www.vuanswer.com
11). You can get an instance of NavigationService by calling the static
NavigationService.GetNavigationService method and passing an instance of the
page.
www.vuanswer.com
www.vuanswer.com
20).Navigation Window always has a journal but frame may depending on its
JournalOwnership = OwnsJournal, UseParenJournal, Automatic
21). When frame has journal it has back/frwd buttons but can set
NavigationUiVisibility = Hidden
www.vuanswer.com
www.vuanswer.com
3). Basic benefit of Silverlight is that it is cross-platform. But WPF browser based
applications just run on windows.
4). In Web Based applications the journal of Application and Web Browser are
integrated.
8). Data can be given to any web site using two method:
URL Parameter
Cookies
www.vuanswer.com
www.vuanswer.com
11). Two steps of making full-trusted Web Browser App.
Change:
<targetzone>Internet</targetzone>
to
<targetzone>Custom</targetzone>
Add:
<permissionset class = “System.Security.Permissionset” version = “1” ID = “Custom”
samesite = “site” Unrestricted = “true”/>
12). To publish a web based application use VS publishing wizard or mage tool in SDK
and copy files to webserver which must be configured to serve it.
13). Users can install and run a web based application just by navigating to a URL.
17). Localization:
Localization means that your application can target more than one target languages or target
Grammers.
18). In Order to localize resources its necessary to make them embedded resources.
www.vuanswer.com
www.vuanswer.com
2). Logical Resources are arbitrary .net objects stored and named in an element
Resource Properties.
3). By using logical resources we can save change in one place and have different
effects. Like you can change brushes in one place and have different effects .
4). Logical Resources can further be categorized in “Static Resources” and “Dynamic
Resources”.
7). Static Resource markup extension walks the logical tree or even application level
or system Resources.
www.vuanswer.com
www.vuanswer.com
13). The key benefit of logical resources is that Use and definition becomes seprate.
14). System Resources are such resources which are shared by al application For
Example: System Color, System font, System Parameters.
www.vuanswer.com
www.vuanswer.com
1). Data Binding allows to declaratively bind two different properties in xaml.
3). Binding binds two propertiews together and keeps a communication channel open.
www.vuanswer.com
www.vuanswer.com
</listbox>
<listbox IsSynchronizedWithCurrentItem = “True” DisplayMemberPath = “Size”
ItemSource = “{Binding source={StaticSource photos}}”
</listbox>
13). With Data Template User Interface are auto-applied to arbitrary .net object when
it is rendered.
www.vuanswer.com
www.vuanswer.com
16). Value Converter is a custom Logic that morphs Source value into Target Type.
www.vuanswer.com
www.vuanswer.com
www.vuanswer.com
www.vuanswer.com
if(view.IsCurrentBeforeFirst)
view.MoveCurrentToLast();
}
void next_Click(Object sender, Routedevent e)
{
IcollectionView view =
CollectionViewSource.getDefaultView(this.FindResource(“photos”));
view.MoveCurrentToNext();
if(view.IsCurrentAfterLast)
view.MoveCurrentToFirst();
}
14). If you have multiple target elements connected to the same Custom View then their
IsSynchronizedWithCurrentItem = “True” by default and it is “false” in Default
View.
15). Data Providers are kind of classes which made it simple for us to access certain
kind of data.
www.vuanswer.com
www.vuanswer.com
www.vuanswer.com
www.vuanswer.com
1). Object Data Provider provides us some facility which are useful for binding to
objects which are not designed for binding.
2). Asynchronous Data Binding means that the property that you want to access should
be done in background.
5). Binding to a method is useful for classes that are not designed for Data Binding.
6). Convert Method is used when bringing data from Source to Target
7). Convert Back is used when bringing data from target to source.
www.vuanswer.com
www.vuanswer.com
<ObjectDataProvider x:key=”DataProvider”
ObjectType=”{x:Type local:photos}”
MethodName = “getFolderName”/>
10). One-Way Binding means the target is updated whenever the source changes.
11). Two-Way Binding means change to either the target or source updates the other
13). One-Time binding is like one-way except changes to the source are not reflected at
the target. The target retains a snapshot of the source at the time the Binding is
initiated.
15). Validation Rules are just like simple classes that are used to ensure the proper
working of the application.
16). Binding has ValidationRules Property that can be set to one or more validation
rules
17). ExceptionValidationRule says that you can update a source if updating a source
does not cast an exception.
www.vuanswer.com
www.vuanswer.com
3). Time slicing means giving time to a thread then we slice and run another thread
then come back and so on.
7). When you call t.join() it means you want to wait for t to finish.
www.vuanswer.com
www.vuanswer.com
10). Locks are a way to ensure that if you are in area of a code then no other thread will
be allowed to enter that area of thread. And are used when threads are sharing
shared data.
www.vuanswer.com
www.vuanswer.com
for(int i = 0; i<10; i++)
{
int temp = i;
new Thread(()=> Console.Write(temp)).Start();
}
www.vuanswer.com
www.vuanswer.com
1). BeginInvoke and Invoke are such methods that can be called from any other thread.
www.vuanswer.com
www.vuanswer.com
ThreadPoool.QueueUserWorkItem(notUsed=> Console.WriteLine(“Hello”));
Task.Run(()=>Console.WriteLine(“Hello From Task”));
9). ThreadPool saves the overhead of thread creation, management and termination.
10). ThreadPool creates or reduces real threads using hillclimbing algo to maximize
CPU usage and reduce time slicing.
11). Threads of ThreadPool are always Background threads which means they are not
going to be deleted they are just waiting for work items.
13). Starting a task is like creating a thread except started right away(hot) means that
there is no need to explicitly start a task.
www.vuanswer.com
www.vuanswer.com
throw;
}
16). Create a task which you can wait and attach continuations. Controlled by the
following operations:
public class TaskCompletionSource<TResult>
{
public void SetResult(TResult result);
public void SetException(Exception exception);
public void SetCanceled();
public bool TrysetResult(TResult result);
public bool TrySetException(Exception exception);
public bool TrySetCanceled();
}
www.vuanswer.com
www.vuanswer.com
4). For CPU bound we can start and return task and are asynchronous tasks.
www.vuanswer.com
www.vuanswer.com
}
Console.WriteLine(“Done”);
9). Asynchronous tasks means doing some work then returning some result then
completing the rest.
www.vuanswer.com
www.vuanswer.com
_button.IsEnabled = false;
String[] urls = www.albahri.com www.orielly.com www.linqpad.net.Split();
Int totallength = 0;
try{
foreach(String url in urls)
{
var uri = new Uri(“http://”+url);
Byte[] data = await new WebClient().DownloadDataTaskAsync(url);
_results.Text+ “Length of “+url+ “ is “+data.Length+Environmentr.newLine;
TotalLength+=data.Length;
}
_result.Text+=”Total length : “+TotalLength;
}
catch(WebException ex)
{
_result.Text+=”error: “+ex.Message;
}
finally{_button.IsEnabled = true;}
}
2). We can return a Task from void function without explicitly returning it.
3). If you have to write asynchronous function then follow three steps:
Write its totally synchronous version
Then use await and async
Then use returnand return Task in place of void
www.vuanswer.com
www.vuanswer.com
await task;
Console.WriteLine(“Done”);
}
async Task<int> GetAnswerToLife()
{
var task = Task.Delay(5000);
await task;
int answer = 21*2;
return answer;
}
7).Example of Cancellation:
class CancellationToken
{
public bool IsCancellationRequested{get; private set;}
public void Cancel(){IsCancellationRequested = true;}
public void ThrowIfCancellationRequested();
{
If(IsCancellationRequired)
Throw new OperationCancelledException();
}
}
www.vuanswer.com
www.vuanswer.com
Task.Delay(5000).ContinueWith(ant=>CancellationSource.Cancel());
9). Cancellation can even be used Task.Wait i.e. Synchronous methods but have to call
cancel from another task. Cancellation is useful for timeouts.
10). In Task-Based Async Pattern (TAP) we create a “Hot” task From Task or
TaskResult.
13). Pseudo Concurrency means a program is running and awaiting for something then
resuming and then awaiting.
www.vuanswer.com
www.vuanswer.com
4). Data Parallelism is easier to perform and scales well, it is also structured.
5). Concurrent collections are useful when you want a thread-safe collection.
www.vuanswer.com
www.vuanswer.com
8). Parallel.Invoke:
Executes an array of delegates in parallel.
10).Example of Parallel.For:
for(int i=0; i<100; i++)
foo(i);
Parallel.For(0, 100, i=>foo(i));
Parallel.For(0, 100, foo);
14). Concurrent Collections are three times slower than normal collections in writing
but not the case with reading.
15). Concurrent Collections include :
Concurrent Stack
Concurrent Queue
Concurrent Bag
Concurrent Dictionary
www.vuanswer.com
www.vuanswer.com
www.vuanswer.com
www.vuanswer.com
2). Java Script is built-in all platforms and is supported by all web-browsers.
• 4). JS was introduced in 1995, originally named with LiveScript but got populated
with most hot name “Java”, MS introduced jScript... their version of JS for IE,
5). JQuery:
• JS is a prog language... can be hard for some... also browser incompatibilities make
testing difficult
• jQuery is a JS library intended to make JS programming easier
• jQuery soles JS complexity and browser incompatibilities
• can do things in single LOC that would take hundreds
• many advanced features come as jQuery plugins
• used on millions of websites
6). In HTML:
• at least three tags ... html root tag, head tag containing title etc, and body tag containing
all parts to be rendered in browser window
• <p></p> is paragraph <strong></strong> is emphasis <a href=“http:...”></a> is a
hyperlink... XML attribute and value
• validating html means checking if all tags appropriately closed etc.
www.vuanswer.com
www.vuanswer.com
9). CSS says that take “this” and make “this” look like “that
11). CSS can do more powerful stuff, like add border, change margins, and even control
exact placement on web page
12). JS can add/remove/change CSS properties based on input or mouse clicks... even
animate from one property to another... like yellow to red... or animate across
screen by changing position
Explanation:
www.vuanswer.com
www.vuanswer.com
14). Concurrent Collections are three times slower than normal collections in writing
but not the case with reading.
15). JS is an interpreted language means each line of code is compiled at run time.
www.vuanswer.com
www.vuanswer.com
www.vuanswer.com
www.vuanswer.com
www.vuanswer.com
www.vuanswer.com
$(‘a[href *= “missingmanual.com”]’): we need tags with “href” having string
“missingmanual.com”
14). Concurrent Collections are three times slower than normal collections in writing
but not the case with reading.
15). JS is an interpreted language means each line of code is compiled at run time.
www.vuanswer.com
www.vuanswer.com
www.vuanswer.com
www.vuanswer.com
• prefs.unshift('test'); prefs.unshift('test',’test2’); ... insert at start
• shift() gets/removes the first element... queue using push/shift
• pop() removes last... stack
www.vuanswer.com
www.vuanswer.com
27). When acting on each element in selection key word Each is used like this:
www.vuanswer.com
www.vuanswer.com
34).JQuery Events:
• hover
• toggle is like hover except worked on and off by clicks
• event object is passed to all functions handling events
www.vuanswer.com
www.vuanswer.com
www.vuanswer.com
www.vuanswer.com
1). Web events also have an event object just like desktop event object.
7). Examples:
www.vuanswer.com
www.vuanswer.com
11). Forms:
<input name=”quantity” type=”text” id=”quantity”>
www.vuanswer.com
www.vuanswer.com
<input name=”total” type=”text” id=”total”>
var unitcost = 9.95;
var amount =\$(‘\#quantity’).val();
var total = amount*unitcost;
total = total.ToFixed(2);
\$(‘\#total’).val(total);
www.vuanswer.com
www.vuanswer.com
1). Ajax is a term which allows us to talk to server remaining within JS.
3). JS, server-side programming, and web browser, all work together
www.vuanswer.com
www.vuanswer.com
newXHR.send('q=javascript'); POST
receive response
callback invoked and XHR receives status, text response, and possibly an XML response
8). The basic concept of POST is that if you want to post a lot of data then instead of
sending it via URL you can insert this into the request body.
9). The Web Server Request can respond in the following states:
• status = 200/304 all ok, 404 file not found, 500 internal server error, 403 access forbidden
8). The JQuery simplifies all steps except that of changing the webpage
12). The better way to use Get() and Post() is object literal i.e.
var data = $.post('rankMovie.php',
{
rating: 5,
user: 'Bob' }
); // end post
www.vuanswer.com
www.vuanswer.com
13). Serialize is used for form submission in JS by so that the page may not reload.
15). third parameter in get() and post() is call back. We write a function that will
process data returned by server.
19). JASON:
• JS format... method for exchanging data
• JSON is JS so its quick n easy for JS
• no XML like parsing
• JSON is a JS obj literal
• {
• firstName: 'Frank',
• lastName: 'Smith',
• phone: '503-555-1212'
• }
• OR
www.vuanswer.com
www.vuanswer.com
• {
• 'firstName': 'Frank',
• 'lastName': 'Smith',
• 'phone': '503-555-1212'
• } (MUST use if names have spaces etc.)
• server returns a string formatted like a JSON obj literal
• jQuery getJSON method
• like get but data passed to callback will be a JSON object
• e.g. var bday = {
• person: 'Raoul',
• date: '10/27/1980'
• };
• bday.person // 'Raoul'
• bday.date // '10/27/1980'
•
www.vuanswer.com