LaVOZs

The World’s Largest Online Community for Developers

'; .net - Cancelling asynchronous remoting call - LavOzs.Com

I have a client-server architecture where client communicates with the server using .NET Remoting. Server handles all business logic and database interaction. I need to add an operation which may take a while to execute and the dataset it returns might be quite large. I'm thinking of employing asynchronous call for that. Now the problem arises: assume, the client made this async call, operation started SQL query, and user either closes the client or clicks Cancel -- what will happen to the operation? Is there any way to cancel the pending async call, which is busy talking to SQL server?

Thanks.

You could design your client/server interaction so that the server let a worker thread do the SQL stuff so that it was ready to receive another call from the client. So, the client makes call 1 and says do SQL work. The server gives that work to the worker thread and is ready for new incoming. Then the client makes call 2 and says, "never mind". The server would do some bookkeeping to make sure it doesn't call back to the client when the worker thread is done.

Can the server safely interrupt the worker thread. I'm not sure. Would that have any affect on what SQL Server is doing. Not sure.

What do you do now with call in progress when client closes application? You can do the same thing with asynchronous call.

Yes, async is the way to go for long-running requests. If result set is big enough, you can even think about sending chunks of it with several responses from server.

Of when user clicks Cancel, you would send a new message to the server stating you are not interested in results anymore. If the SQL request is running on thread pool, you cannot really cancel it.

Related
.NET Remoting Client's Problem when running on the machine with Multi NICs
.NET Remoting switching channels by itself
Cancel asynchronous operation
WCF behaviour configuration as .NET Remoting
Do asynchronous operations in ASP.NET MVC use a thread from ThreadPool on .NET 4
.NET Remoting giving a KRB_AP_ERR_MODIFIED Error
.NET 4.5 SslStream - Cancel a asynchronous read/write call?
Wrap .NET Remoting async method in TPL Task