Tuesday, January 21, 2020

Xamarin Forms Best Practices Enable the XAML compiler

XAML can be optionally compiled directly into intermediate language (IL) with the XAML compiler (XAMLC). XAMLC offers a number of benefits:
  • It performs compile-time checking of XAML, notifying the user of any errors.
  • It removes some of the load and instantiation time for XAML elements.
  • It helps to reduce the file size of the final assembly by no longer including .xaml files.
using Xamarin.Forms.Xaml;
...
[assembly: XamlCompilation (XamlCompilationOptions.Compile)]
namespace PhotoApp
{
...
}
using Xamarin.Forms.Xaml;
...
[XamlCompilation (XamlCompilationOptions.Compile)]
public class HomePage : ContentPage
{
...
}
view raw XamlCompile.cs hosted with ❤ by GitHub

TPL Task Parallel Library mapping to Async Await

What is async/await?

The async and await keywords were introduced in .NET 4.5 to make calling async methods easier and to make your async code more easily readable. 
The async/await API is syntactic sugar that uses the TPL (Task Parallel Library) behind the scenes. If you wanted to start a new task and have code run on the UI thread after the task completes prior .NET 4.5, your code would have looked something like this:

// Start a new task (this launches a new thread)
Task.Factory.StartNew (() => {
// Do some work on a background thread, allowing the UI to remain responsive
DoSomething();
// When the background work is done, continue with this code block
}).ContinueWith (task => {
DoSomethingOnTheUIThread();
// the following forces the code in the ContinueWith block to be run on the
// calling thread, often the Main/UI thread.
}, TaskScheduler.FromCurrentSynchronizationContext ());
view raw tpl.cs hosted with ❤ by GitHub
Using async/await, the above code becomes just two lines of it.In the nutshell it does exactly the same thing.
await DoSomething();
DoSomethingOnTheUIThread();
view raw asyncawait.cs hosted with ❤ by GitHub
The above code gets compiled behind the scenes to the same TPL code as it does in the first example, so as noted, this is just syntactic sugar, and how sweet it is!

Monday, January 13, 2020

Fiddler Web Debugging Proxy - Filtering by Process

Cool Tip to begin with:

If you are in fiddler IDE , at the bottom there is status bar. Look closely at left side of bottom status bar. You will notice by default All processes. You can filter and can view process related to web browser or Non web browser( For e.g word, pdf etc). Even you can hide them.