Skip to content

Conversation

qazq
Copy link

@qazq qazq commented May 23, 2017

In some cases, add/remove workflow at persistence store will throw an
exception. ("Collection was modified; enumeration operation may not execute.")

In some cases, add/remove workflow at persistence store will throw an
exception. ("Collection was modified; enumeration operation may not execute.")
@danielgerlag
Copy link
Owner

danielgerlag commented May 23, 2017 via email

@qazq
Copy link
Author

qazq commented May 23, 2017

MemoryPersistenceProvider

@qazq
Copy link
Author

qazq commented May 23, 2017

This is my testing code.

            var host = serviceProvider.GetService<IWorkflowHost>();
            host.RegisterWorkflow<HelloWorldWorkflow>();        
            host.Start();

            Thread.Sleep(100);
            for (int i = 0; i < 100; i++)
            {
                host.StartWorkflow("HelloWorld", 1, null);
                if (i % 10 == 0)
                {
                    Thread.Sleep(1000);
                }
            }

It has the chance to happen the exception.

Copy link
Owner

@danielgerlag danielgerlag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR...
Would it work if we simply changed the List<> fields to ConcurrentBag<> fields, rather than adding the locks?

@danielgerlag danielgerlag merged commit 747233c into danielgerlag:master Jun 4, 2017
@qazq
Copy link
Author

qazq commented Jun 5, 2017

ConcurrentBag<> seems cannot remove a specific item, so I add the locks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants