Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New exercise for Asynchronous programming in C# #1894

Open
mdrakiburrahman opened this issue Mar 6, 2022 · 11 comments
Open

New exercise for Asynchronous programming in C# #1894

mdrakiburrahman opened this issue Mar 6, 2022 · 11 comments

Comments

@mdrakiburrahman
Copy link
Contributor

It would be great to have an exercise on Async programming as it is used in many real world dotnet applications.

The Golang track had one called "Prallel Letter Frequency"that introduce Goroutines, which I found quite useful.

@ErikSchierboom
Copy link
Member

We have the same exercise (https://github.com/exercism/csharp/tree/main/exercises/practice/parallel-letter-frequency), but it looks like the implementation is actually wrong and uses synchronous code. Would you be interested in converting the exercise to allow for asynchronous (rather: parallel) programming?

@mdrakiburrahman
Copy link
Contributor Author

@ErikSchierboom - sure! I've never contributed a scenario to Exercism - but if you can point me the necessary reqs (Unit testing etc) and assign the issue to me, I'm happy to contribute.

@ErikSchierboom
Copy link
Member

@mdrakiburrahman You don't even have to create a new scenario, just to update the existing one to accommodate for people using parallel execution. So what I think needs to be done is to change the Calculate method to return a Task<Dictionary<char, int>> instead of Dictionary<char, int>. This means updating three files:

Finally, you should also add yourself to the exercise's contributors list in https://github.com/exercism/csharp/blob/main/exercises/practice/parallel-letter-frequency/.meta/config.json#L5

@skurt
Copy link

skurt commented Jul 5, 2024

Hi,
I stumbled upon this after watching and reading about a zillion hours of async/await training materials and still not being able to wrap my head around it.
It looks like a good way to practice.

However - I seem to be missing the goal of the exercise - what to do and what the output should be?
I ran the project ParallelLetterFrequency and it's ok. But I assume that downlading the project, making one default and running it isn't the point of async/await practise program.

So...what am I missing?
Thank you

@ErikSchierboom
Copy link
Member

However - I seem to be missing the goal of the exercise - what to do and what the output should be?

Did you check the README.md that is included?

@skurt
Copy link

skurt commented Jul 9, 2024

I didn't.
Also, there is none in the excercise.

However, based on your suggestion, I found file instructions.md, which contains this:
Count the frequency of letters in texts using parallel computation.

Parallelism is about doing things in parallel that can also be done sequentially. A common example is counting the frequency of letters. Create a function that returns the total frequency of each letter in a list of texts and that employs parallelism.

Which doesn't tell me much, but in the meantime I figured that out from the tests.

What I got stuck on is - I'm supposed to make things parallel.
I don't know how, but that's beside the point now.
As soon as I do something paralell, I must make the procedure 'async' and I must change it's return type.
But at the same time - I can't, because I have the tests that call s specific method.
Can you please give me the question I should be asking how to solve this situation. I read everything I found, I asked people and there seem to be no answers to my questions.
But since I assume you know what you're doing and there is a solution to this, I must be asking wrong questions.

@ErikSchierboom
Copy link
Member

However, based on your suggestion, I found file instructions.md, which contains this:
Count the frequency of letters in texts using parallel computation.

How are you doing these exercises? You should be doing them via the website: https://exercism.org/tracks/csharp/exercises Then you can either use the CLI or the online editor.

@skurt
Copy link

skurt commented Jul 9, 2024

I downloaded the code from one of your previous comments in this thread (https://github.com/exercism/csharp/tree/main/exercises/practice/parallel-letter-frequency)
I run the project locally, in Visual Studio and running the tests from there.

Does that have any connection to the fact that if something's calling my method in a non-async way and I want to do the method run threads, which forces me to make it async...which I can't do...etc. etc. etc.
...which is actually the reason I started with this excercise in the first place.

@ErikSchierboom
Copy link
Member

Meaning you didn't use the CLI? If so, please do that. And you can use the exercism discord channel for questions. Link is on the website

@skurt
Copy link

skurt commented Jul 10, 2024

I did not. I also don't know how.
And I honestly have no intention of doing that.

I found your exercise and I wanted to learn something by doing it. And that something is not where is the entry point to the world of your exercises.
I'm sorry and thank you for your time.

@skurt
Copy link

skurt commented Aug 26, 2024

This may not be the solution for every "kill async and continue non-async", but should someone need a hand handling this in the future, here's a piece of code that helped me in one of such situations that I encountered.
I did not write it, nor do I understand how does it work, but it works!
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants