Putting await for async method call is mandatory in .net ?? For example, I have a redis set command that I don't want to wait for.
.....statements....
await redis.Hashes.Set(db, mainKey, value);
.....statements after set command......
I don't want to pause the execution of my method in set command. So I removed 'await'.
.....statements....
redis.Hashes.Set(db, mainKey, value);
....statements after set command......
Is this a good practice??
You can choose to not await a Task, but I not sure it's good practice. If there are exceptions thrown in the called Task you won't know about them.
See https://msdn.microsoft.com/en-gb/library/hh965065.aspx
Also, Booksleeve has been deprecated for quite a while now, and is replaced by StackExchange.Redis. You should probably look to use that instead, if possible.
StackExchange.Redis has a CommandFlags.FireAndForget
parameter that you can specify which will immediately return the default value and not wait around for the command to complete.
connection.GetDatabase().HashSet(key, field, value, flags: CommandFlags.FireAndForget)