IsCancellationRequested is true in midnight operation


I am facing an issue while during midnight operation for my winform application.

Actually, I am trying to run a long running tasks and for this, I have scheduled the timing (i.e. StartTime = 23:59 and EndTime = 02:00), but, when I saves this time and when the time period hits >=00:00:00, that time I am getting

System.Data.SqlClient.SqlException: 'A severe error occurred on the current command. The results, if any, should be discarded. Operation cancelled by user.

The full exception is:

Caused by: Type : System.Data.SqlClient.SqlException Message : A severe error occurred on the current command. The results, if any, should be discarded. Operation cancelled by user. HResult : 0x80131904 SqlErrorNumber : 0 Source : .Net SqlClient Data Provider at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.SqlDataReader.TryHasMoreRows(Boolean& moreRows) at System.Data.SqlClient.SqlDataReader.TryReadInternal(Boolean setTimeout, Boolean& more) at System.Data.SqlClient.SqlDataReader.Read()

In this scheduled time period, Heavy database operation is being performed. On the other side, If I saves the scheduled time period within the 24 hours period (i.e StartTime = 10:00:00 and EndTime = 11:30:00), that time everything is fine, all operation complete successfully.

I am using the "CancellationToken" here, I think, the operation attempts a cancellation at midnight, something must be launching that cancellation request.

Can anyone please suggest me why exactly the cancellation request is being active at midnight and why not within 24 hours period ?

It will be great, If anyone will share his thoughts on it.

Please let me know, if any more details needed.

asked on Stack Overflow Nov 8, 2020 by user14285851

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0