About Undo/Redo my data ? (C++/Rhino 5)

I declare a variable ,such as int m_Procees , in myplugIn.h
and it will be saved in 3dm file via myplugIn::WriteDocument() .

The problem happened after Undo command because it don’t undo the value of m_Procees.

Example:
m_Procees = 1.
The m_Procees is changed to 3 by runing command_A.
Runing Undo command.
The m_Procees is still 3 ,not 1.

How to solve this problem ???

Only Rhino document-based objects are undoable,not member variables on your plug-in object.

But, Rhino does support adding custom undo events. To learn how, review the following article.