Translate

Thursday, October 03, 2019

Async and Await notes

- Await Keyword introduces continuation which is executed after the async operation 
- The coninuation is executed on the original context in this example that is the UI thread. 
- The await keyword introduces a coninuation allowing to get back to original context. 
- Marking a method as async introduces the capability of using the await keyword to leverage the asynchronous principles. 
- Avoid async void at all cost 
- Using Async void is allowed only for Event HAndlers 
- Methods marked as async taks will automatically have a Task returned without explicitly having to return anything,  then the caller can await the Task 
- If we do not use await keyword on async methods the inner exceptions will be swallowed. Always use the await keyword to validate your tasks. 
- Exceptions occuring in an async void cannot be caught 
- Do Not 
- No Async void 
- Avoid .Result or .Wait 

- Do 
- Async and Await together 
- Always return a Task from an Async method 
- Async and await all the way up. 

- Task Represents an asynchronous operation 
- Task.Run() queues the work passed as the action to run on a different thread by using the thread pool 
- Before Loading 
- Task.Run() queues the work which completes instantly 
- After Loaded --> Executes immediately after Task.Run()
- A task can easily for block the UI so be very careful when wrapping synchronos code and make sure it does not contain blocking code
- ContinueWith creates a continuation which runs asynchronously this means that it also returns a Task. 
- Calling the Result property on a task is not a problem as long as the task has finished its asynchronous operation. 
- A big difference between using await and ContinueWith is the fact that ContinueWith is not back on the original context.
- In case of ContinueWith if there's an error in the async operation then we need to define the TaskContinuationOptions to specify what needs to be done in case of exception. 
- Using await together with try and catch is recommended and does not wrap exception in an aggregate exception. 
- Whenever you use the ContinueWith make sure to validate tasks even when not using async and awat by chaining on a continuation, 
- CancellationTokenSource is used to signal that you want to cancel the operations that utilize the token.
- CancellationTokenSource is coupled with CancellationToken which is passed to async operations to indicate that operation is cancelled or not. 


Friday, June 22, 2018

Basics of git and setting it up with VSCode


  1. Course from Pluralsight : https://app.pluralsight.com/library/courses/git-fundamentals/table-of-contents
  2. Installer from the following link:  https://gitforwindows.org/
  3. Setting VS code as a default editor from the Link: https://blog.soltysiak.it/en/2017/01/set-visual-studio-code-as-default-git-editor-and-diff-tool
Have been learning about GIT and a lot of good links were shared by my colleagues, to get a good introduction to git I bought this ebook: https://abookapart.com/products/git-for-humans

Follwing links are easy to read and useful to have consistency across the team: 
Associating Text Editors with Git

Git Log pretty formatting

Advanced Git Logs

A Note about git commit messages:

How to Write Commit Messages

Data Integrity of Git is pretty well described in the talk: 






Tuesday, August 29, 2017

Building a docker Image with iis and pre-requisites

Steps to do: 

- Run the container with the command  docker run -it 4f222 cmd.exe 
- Image which is run here microsoft/windowsservercore
- this should open the command prompt 
- then the navigate through the command prompt (to c:\ProgramFiles\powershell\powershell.exe) to get a powershell command prompt
- In the powershell execute: Install-WindowsFeature -Name Web-Server, Web-Mgmt-Tools
- Above commnand should enable IIS Server on the container and also install management tool for that 
- To test the successful installation of the web-server try executing the iisreset in the prompt, you should be able to see the iisreset message then. 
- To know the full folder name of the docker image we need to run the command: docker inspect -f '{{.Id}}'  e9bb03ced109(ContainerID)
- Best option is to mount a folder to the image and then have it as a part of the image so that it can be accessed within the image. 
- command to run in the mount mode: docker run -it 4f222 powershell.exe --mount type=bind,source=c:\Hackathon,target=c:\Hackathon (Some how this did not work today)
- Trying another suggestion form StackOverflow: https://stackoverflow.com/questions/40313633/how-to-copy-files-from-local-machine-to-docker-container-on-windows
- Container name is required to execute the command, to get the container name: 
docker ps --format "{{.Names}}"
- Modified command for this machine: 
docker cp c:\Hackathon sharp_euclid:c:\Hackathon

Tuesday, June 13, 2017

Containers on Windows

Learning stuff about containers and trying to figure out how to run a asp.net webapi inside them. 

Links which I am referring as I am moving forward: 


Here's a link talks about creating VM with containers on Azure: https://blogs.msdn.microsoft.com/jcorioland/2016/10/13/getting-started-with-windows-containers/





Run command for the docker has many switches: 

Wednesday, July 09, 2014

Web.config Transformation Syntax for Web Project Deployment Using Visual Studio

Needed to do some work on the web.config transformations, I was finding difficulty in locating the complete set of functions which can be set to either xdt:Transform or on xdt:Locator. \

Finally found a cool link on msdn which served my purpose: 

Another link which helped: 

Thanks
Dibyendu

Friday, March 28, 2014

Self answered question on Stackoverflow: how-to-get-typeas-in-request-gettype-of-a-request-message-in-service-behavior

Stackoverflow is the lifeline of all the developers these days. I created a question and answered it for myself and this is my first attempt at asking a question and answering it, till date no one has upvoted the answer but I would still like to paste the link here: 


Thanks
Dibyendu

Thursday, March 13, 2014

Faking Static constructor

I have been fixing up some legacy test cases written against Typemock 6.0.8 and was planning to get it running against Typemock 7.4.3. 

As always legacy code was faking some objects which were internally referring objects which had static constructors. 

Couple of links which helped me here : 




Thanks
Dibyendu