c# - SignalR polling not always returning accurate database results -
In my app, I start an import process by uploading an XML file. After uploading it, a series of stored procedures run and the XML file is parsed, and the data is inserted into many different tables. As soon as its progress, a My main goal is to display import progress using signal R. I have a hub method which is okay for voting, I am seeing the updated timestamps in the UI. However, this problem is that counting is always 0 (initial value), or sometimes it is sometimes read and looks like random 985. If it reads any value, it only does once and will not change it again. Here is my hub method: Below is my In addition to testing, I tried to put a button on my UI which calls the same You are doing one of the big frames of the unit framework, you have long lived DbContext Never should it. In this case, you are having problems with the unit trackworches change tracker by default EF It means by default, on each EF query, EF will only drearize the rows to the object, the IFF key does not match any object Changes to the theme Tracker So you have used the same example of each loop in EF reference, EF only when you query (SQL runs but does not make EF or uses cached values Object is expected to change) You have several options to fix this. statistics table is updated to reflect the inclusive progress. The
statistics table has 4 columns:
batch id ,
batchcount ,
processcode , and
errorCount .
Batch count All records are counted if the records are properly inserted without any problems, then
process count is increased by 1, if it fails then < Code> ErrorCount increases with 1. (These two columns are always changing during the import process)
public void BeginPolling () {when (true) {var stats = _repository .GetImportStats (); Var message = "Preparing file ..."; If (statistics = zero) {message = DateTime.Now + "- Calculate:" + stats.processCount.ToString (); } Else {message = DateTime.Now + "- Stats returned results."; } // Displays a message on a UI on my UI client. Caller.show progress (message); // I have tried many sleeping times (1000, 5000, 10000) thread. Sleep (5000); }}
_repository.getImportStats method, for testing purposes it only takes hold of the first (and only) records: < Pre>
public statistics GetImportStats () {DataContext.Stats.FirstOrDefault (); }
GetImportStats () method to an AJAX, And it always gives
process work ok, so I think the problem is within my signal implementation implementation any help is appreciated!
mergeption. The append uses only .
MergeOption.OverwriteChanges on each track.
Comments
Post a Comment