question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

System.OperationCanceledException When Disposing DataStore

See original GitHub issue

I’m using your library to implement a set of local data stores. I love this library and the implementation. I am seeing a behavior I am trying to resolve as I am implementing unhandled exception handling now in the my .NET 6 WPF application. So this keeps tripping it…

Here is an example of one of my methods on one of the repositories:

        public IEnumerable<QuestionSet> GetAll()
        {
            using (var ds = new DataStore(_fileName, true, nameof(QuestionSet.PrimaryKey)))
            {
                var coll = ds.GetCollection<QuestionSet>();
                return coll.AsQueryable().ToList();
            }
        }

After the ‘using’ exits I always get a: System.OperationCanceledException

If I don’t use ‘using’ or do not Dispose, I don’t see the exception.

Should I not be wrapping the DataStore object in a using? Or am I using the library in the wrong way?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ttucommented, Jan 15, 2023

@nabeelio Good that you found a workaround👍

New version with the fix in now released https://www.nuget.org/packages/JsonFlatFileDataStore/2.4.1

0reactions
nabeeliocommented, Jan 10, 2023

Hi @ttu sorry for the delayed response, just getting back to this. Thanks for the fix! I stopped calling Dispose() manually and that ended up fixing it too, but maybe there were still some side-effects which are fixed. I’ll upgrade the library today! Thanks again!

Read more comments on GitHub >

github_iconTop Results From Across the Web

C# : OperationCanceledException : The operation was ...
An OperationCanceledException exception typically means that an Event Hubs service operation timed out. In your stack trace, it appears that ...
Read more >
The operation was canceled - when querying statistics
System.OperationCanceledException: The operation was canceled - when querying statistics ... Just recording here what we've seen on our integration test suite.
Read more >
OperationCanceledException Class (System)
The exception that is thrown in a thread upon cancellation of an operation that the thread was executing.
Read more >
Stop wasting server resources by properly using ... - YouTube
TaskCanceledException inherits from OperationCanceledException, so you only really need to catch the latter.
Read more >
Thread: [RESOLVED] Cancellation of task
But when I do I get an error stating: System.OperationCanceledException: 'The operation was canceled.' and sends me into a break screen.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found