Share via

how to lock memoryStream?

mc 7,186 Reputation points
2023-11-17T03:29:39.01+00:00

I create multi threads to operate the MemoryStream how to lock it to prevent other thread to write it?

Developer technologies | .NET | .NET Runtime
Developer technologies | .NET | Other
0 comments No comments

Answer accepted by question author

Jiachen Li-MSFT 34,241 Reputation points Microsoft External Staff
2023-11-17T09:09:19.0833333+00:00

Hi @mc ,

You can use lock statement or Mutex Class to synchronize access to the MemoryStream among multiple threads to prevent simultaneous writes or conflicting access.

Best Regards.

Jiachen Li


If the answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Was this answer helpful?

0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.