I am kinda new to Xamarin.Android and still have a steep learning curve ;-). But i approached a problem which i don't find a solution even after a few days of googling and YouTube-ing.
Do somebody know how to call a async Task from another Class?
i want to call the public async Task ReadStringAsync() from the class MainActivity. How can i do that?
i want to call this:
class TextfileRead { string[] StrData; String filename = "Arbeitszeiten.txt"; String filepath = "myFileDir"; String fileContent = ""; public async Task<string> ReadStringAsync() { var backingFile = Path.Combine(filepath, filename); if (backingFile == null || !System.IO.File.Exists(backingFile)) { return "oO, irgendwas ging schief"; } string line; using (var reader = new StreamReader(backingFile, true)) { //string line; while ((line = await reader.ReadLineAsync()) != null) { //return line; } } return line; } https://stackoverflow.com/questions/65939662/c-sharp-call-interclass-asynch-task January 28, 2021 at 10:58PM
没有评论:
发表评论