To follow the Task-based Asynchronous Pattern and usual naming conventions (methods should be verbs, not nouns), your Authentication
method should be named something like AuthenticateAsync
.
Also, ifIf this was a real code, you shouldn't use Task.Run()
on a synchronous method, instead the whole CheckIfNameExistsInDatabaseOnServer
method should be asynchronous, since accessing the DB is IO-bound.
The parentheses in your ternary expression are not necessary (also following Malachi's advice about newlines):
string outputString = await Authentication(usernameTextBox.Text)
? "Name exists"
: "Name does not exist";