C # Shared Memory instance

Source: Internet
Author: User

There is a C # Shared memory class on the Web, but the functionality is too simple, and write memory is written every time from the beginning. Therefore, this has been improved, and made a small example for the needs of the people for reference.

Main improvement points:

Complete memory Read and write functionality by taking advantage of part of the shared memory (hereinafter referred to as the "Data Information area") to store the data information stored in the current memory (count and length or add additional information).

When reading and writing memory, read and write the data information area.

1. Write Shared memory

Writes backward based on the current usage length of shared memory.

2. Read Shared memory

Reads all data from the starting position of the shared memory (excluding the data information area) to length.

3. Key points

The IntPtr type M_pwdata is manipulated as a pointer to enable the data to be read and written from any location in memory.

M_pwdatawrite = (INTPTR) (M_pwdata.gethashcode () + m_length + infosize);

4. Can improve the office

In the data information area, the length information of each piece of data is added to enable the free reading of the data without having to start reading every time.

The example screenshot is as follows:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.