So I tried to depict JavaScript Callback in C#

Dhiman Das
May 1, 2021

--

I was learning C# and I came across a situation. But I was not able to solve it. So I decided to try the same situation in JavaScript and guess what. I learnt this beautiful concept call “delegates”.

In this article I am going to give you a simple overview of my situation and how I converted that piece of JavaScript code to C# code. Here we go…

Situation explained: I need to run some code which takes lots of time to finish and this “longRun” code should inform me its progress.

So I created a “Program” class. This class calls a function called “longRunning” of class “Compute”. After each iteration, this functions informs to Main class about its progress. Below are the code examples. Have fun!

Using Javascript:

Using C#

Thank you for reading.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Dhiman Das
Dhiman Das

Written by Dhiman Das

A software developer, who also loves to read self-help book, love to do cycling, love to play music and also entered into the world of content writing.

No responses yet

Write a response