-
Notifications
You must be signed in to change notification settings - Fork 26
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
Nothing is happening #15
Comments
Hi Jay, thanks for creating this issue. It seems like your code is correct. Do you have this code placed within an Async function? To rule out other problems, you could try another async function known to work, for example If that works as expected, there could be a problem with your internet connection. This .NET library retries failed requests automatically, so to get a failure faster you could try lowering the number of retries as explained here. |
Hey Daniel, the file is created, I am just very confused about the debugger not continuing. Here are some details about the code I am using: Public Shared Function GetTranslationForPO(TextToTranslate As String, Optional Context As String = Nothing) As String
Return GetTranslationForPOAsync(TextToTranslate, Context).Result
End Function
Private Shared Async Function GetTranslationForPOAsync(TextToTranslate As String, Context As String) As Task(Of String)
' [truncated version]
Dim AuthKey As String = "01234567-89ab-cdef-0123-456789abcdef:fx" ' Free API Key
Dim Translator As New Translator(AuthKey)
Dim Options As New TextTranslateOptions With {
.Formality = Formality.More,
.TagHandling = "html",
.SentenceSplittingMode = SentenceSplittingMode.NoNewlines
}
' Debugging seems to stop after this step
Await IO.File.WriteAllTextAsync("right-here.txt", "This file is created successfully.")
' I am expecting this to be the next step
Dim TranslatedText = Await Translator.TranslateTextAsync(
TextToTranslate,
FormMain.Settings.LanguageSource.DeepLLanguageCode,
FormMain.Settings.LanguageTarget.DeepLLanguageCode,
Options
)
' I never get here while debugging
Return TextToTranslate
End Function Would love some more insight! Thanks. |
Okay, then if you get the same debugging problem with a system function, it might be something unrelated to the DeepL library. I am not very familiar with Visual Basic code, but it seems like in this StackOverflow thread someone has a similar problem. The answer from Stephen Cleary suggests your problem could be that your program is exiting before the async functions complete? Although you did say the program waits, rather than that it stops. Calling Another idea: do you step through the code line-by-line while debugging, or do you set breakpoints? Breakpoints may work better, because some debuggers lose the execution line with async code. |
I've tried both with the same result. I am familiar with async programming in general (i. e. JavaScript) but in vb.net it's just confusing for me, I really don't understand this behaviour, it doesn't make any sense to me. 😞
My program is not exiting, it's still running and seems to just sit still and I've spent so much time the last days trying to find something online but no luck yet 😖 |
Hi @grandeljay, I looked into this but I cannot reproduce what you saw, using JetBrains Rider. In debug mode I am also able to step through this code without issue.
The expected output is "Hallo" twice (Hello in German). |
Hi together (@daniel-jones-deepl , @grandeljay) The Assembly 'Polly, Version=7.0.0.0' was not found |
@daniel-jones-deepl, thank you for all your efforts so far!
It's the same behaviour for me, nothing is happening. Something seems to be wrong with my IDE or I am totally not understanding how to use it.
OS: Windows 10 |
Hi @grandeljay, I just tested the Program.vb code above in Microsoft Visual Studio Community 2022 (64-bit) Version 17.2.4, on Windows 10, and unfortunately I get the expected output, so I can't reproduce your issue. Debugging also works as expected. |
Hi @AdrianEfford, |
Thanks for all the suggestions! I have tried resetting & reinstalling my IDE (Visual Studio Community 2022) and installing Polly but unfortunately nothing works. In the meantime I will be using the unofficial DeepL library, as this works without any problems for me. It also seems to use async functions but they are executing fine for me. I am really starting to think something is wrong with this library rather than my machine. I am sorry I could not give you enough information to reproduce my issue, please let me know if I can ever try/test something for you, as I would much prefer to use the official DeepL library. |
Hi @grandeljay, C# Deadlocks in Depth – Part 2 Maybe you can started with the following sample replacing the [Do] part:
P.S: Here's a link to a C# => VB.NET converter Telerik Code Converter |
Same thing in C# VS 2022. Unofficial lib works fine. Ugly hack would be to do something like this: (where translator is a configured instance of Translator. |
It's been a couple of years now and I've tried it again on the same machine but a new project. I'm attempting the synchronous way: Dim Translator As New DeepL.Translator("xxxxx")
Dim Options As New TextTranslateOptions With {
.Formality = Formality.PreferMore
}
Dim Task As Task(Of TextResult) = Translator.TranslateTextAsync(
GermanTranslation.GetValue,
LanguageCode.German,
LanguageCode.French,
Options
)
Dim TranslatedText As String = Task.Result.Text It's the same issue for me still: nothing happens when I call Could you please let me know if you can find a mistake in my approach? |
|
I am new to asynchronous programming in .net so I'm hoping that I am making an obvious mistake here. Nothing is happening when I
Await Translator
EDIT: To clarify, I literally mean nothing, there is no error and the code also doesn't continue to execute. It just waits forever after that call.
Please advise. Thanks!
- Jay
The text was updated successfully, but these errors were encountered: