so what happens when I use .Wait () to call the async method ?, will the operations of the whole method be executed synchronously? for example, as shown above, I have three asynchronous operations inside ScanAsync (), SingleOrDefualtAsync, ToListAsync and SaveChangesAsync, so they will be executed in a synchronized way, because I call the ScanAsync method using .wait ()?
The methods that query the database will continue to be executed asynchronously, but the fact that you call Wait means that even if you free the thread, it will not return to ASP.NET ThreadPool as you stop it.
This is also an opportunity for deadlocks because ASP.NET has a custom synchronization context that ensures that the request context is available when continuing with an asynchronous call.
I would recommend using the synchronous API provided by the entity infrastructure instead, as you really cannot use the scalability that you can get from asynchronous calls.
Edit:
In the comments you asked:
How am I doing with hangefire now to eliminate the effect of asynchrony? if so, is it better to use synchronization methods? or using synchronization or asynchronous mode with hangeffire will be exactly the same
First, you need to understand the benefits of async. You do not do it because it is cool; you do it because it serves the purpose. What is this goal? Ability to scale under load. How does it do this? When you await asynchronous method, control returns back to the caller. For example, you have an incoming query, you are querying a database. You can sit there and wait for the request to complete, or you can reuse this thread to serve more incomplete requests. This is true power.
If you are not really planning on receiving a decent amount of requests (for example, you will starve the thread pool), you will not see any benefit from asynchronous use. Currently, as you have implemented it, you will not see any of these advantages, because you are blocking asynchronous calls. All that you see may be deadlocks.