Long Running Task C#

Await and async in .NET 4.5 with C# public Task<string> RunSlowOperationTask()         {             return Task.Factory.StartNew<string>(RunSlowOperation);         } OR var taskData = new CalcTaskData {ForDate = forDate.Value, param2 = Value2};  Task t = new Task(() => DoCalcAsync(taskData));  t.Start(); // Long running Task private async Task DoCalcAsync(CalcTaskData calcTaskData) { // long operation // simulate long wait  (see note below) } Note that […]

Task.Run vs RunSynchronously

Task.Run = Tasks are executed asynchronously on a thread pool thread and do not block the calling thread. ​Task.RunSynchronously: Run on the calling thread, Blocks caller. Both cases need to Wait() to catch exceptions.. TaskScheduler: Latter: Task gets associated with the current TaskScheduler. If the target scheduler does not support running this task on the calling thread, the task will be […]

Export Table to Excel – Server side MVC

Excellent blogpost.. Using ClosedXml Nuget pkg.. ​http://www.c-sharpcorner.com/UploadFile/rahul4_saxena/export-data-table-to-excel-in-Asp-Net-mvc-4/​ Excerpt: public ActionResult ExportReportDataPerReport() DataTable dt = new DataTable(“ReportDataExport”); // tableName = ReportDataExport (also becomes sheet name in Xlsx) // Add Columns to the dt. Then add data using dt.NewRow and dt.AddRow … // Once dt is populated, run below code..             using (var wb = new XLWorkbook())   […]

NPM and Gulp

NPM is Node Package Manager and similar to Nuget. Uses package.json​ instead of package.config. Allows installation of Javascript based packages from the NPM website (npmjs.org). INSTALLING NODEJS and NPM: 1. Install Nodejs (x86 or x64 from the NodeJs.Org) — THIS makes your machine nodejs and npm enabled.. CHECK: Open command line and run node -v and npm -v. We should see […]

Angular 2 First Look

Pluralsight course – Angular 2 First Look (John Papa)  https://app.pluralsight.com/library/courses/angular-2-first-look/table-of-contents Ready to use / run samples: (edit/run in Plunker online) http://a2-first-look.azurewebsites.net/ (or http://jpapa.me/a2firstlook) Further reference n quickstarts: https://angular.io/docs/ts/latest/guide/ https://angular.io/docs/ts/latest/guide/architecture.html

Debug Error 500 – IIS

1. ​Howto force error 500 to enable testing the error output and logging: Navigate to site root or a page with ?someParam=<script> (note: this will be treated a a dangerour script and error 500 thrown). 2. MVC Web.config <httpErrors errorMode=”Custom” existingResponse=”Auto”>       <remove statusCode=”404″ />       <error statusCode=”404″ path=”/404.html” responseMode=”ExecuteURL” /> […]

Shim Shiv Polyfill

Shim=Shiv (latest http://cdnjs.com/libraries/html5shiv) Kind of like polyfills cover over the differences in implementations of features. The way the HTML5 shiv works requires you to put it in the <head> element Also refer to excellent reference on Html5 polyfilling https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-Browser-Polyfills​​