I have the following problem: There is a class MyControl derived from COleControl (which then I want to use in another project )
which has implemented
<do sth on global resources(to draw sth)>
When use many instances of it in mysecond project
at the same time func1 is beeing called from several controls making acces violation. I was trying to use waiting loops (with Sleep) in func1 or in the "for loop" but all in vain.
But when I put in the "for loop" AfxMessageBox -so main program is waiting for user resond while current control from the loop can end func1 separatelly everythings works good -
-so I guess it's a problem of COleCotroll message dispatching scheme.
Can any give me a piece of advice or give me a link concerning his subject
This ATL project is ready (it was made and tested by another person) and works OK when one instance of control is beeing used (as an ActiveX in another project). So it's not a problem, how to make such a project.
Now, I have to make it working in situation of multiple use, and I have problem in synchronizing it (to avoid multiple acces to global resource)
In my example places above, in the loop from main program, all conrols seem to have called their func1() at the same momemnt after the end of the loop (are the oles separete thread waiting until the thread of the main programm ends end then executing).
When in my ATL project (with declaration of my control) I am trying to put some wainting mechanism it hangs up(the control represents a window, func1 calls OnDraw, I've somewhere that OleCtrl have to serve it's drawing events without a break - is it true?)
Yes, I understand that it's not a problem of COM but MyControl implentation.
This class represents a window in which in implementation of OnDraw method I have to use global functions (of a library used in MyControl project, which has to be used here)
<rapainting using global functions and data>
And in my main project I am creating several instance of it. When OnDraw methods are beeing called I'll have access violations. So I want to force MyControl::OnDraw() calls to be executed separatelly.