csharp
csharp copied to clipboard
New exercise for Asynchronous programming in C#
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.
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?
@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.
@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:
- The stub file: https://github.com/exercism/csharp/blob/main/exercises/practice/parallel-letter-frequency/ParallelLetterFrequency.cs#L6. This file should have its
Calculatesignature changed to the above. - The tests file: https://github.com/exercism/csharp/blob/main/exercises/practice/parallel-letter-frequency/ParallelLetterFrequencyTests.cs. The tests should all be using async tests that work with the Task-based
Calculatemethod. - The example file: https://github.com/exercism/csharp/blob/main/exercises/practice/parallel-letter-frequency/.meta/Example.cs This file should also be updated to use the new signature and then be modified toprocess the results in parallel.
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
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
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?
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.
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.
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.
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
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.