SliceO_Class::Lock_Set

 

This method add the value "val" to the variable "m_lock".  If the resulting value is "0" then the lock is cleared.

 

Note:

 

m_lock will never be smaller than "0".

 

 

Syntax

 

void          Lock_Set(

          int val

) ;

 

 

Parameters

 

val

                    Value to add to the "m_lock" variable.

 

 

Return value

 

You must insure that you remove all locks before you exit a function.  Failure to do so will leave the instance locked and sliceOmatic will no longer redraw it.

 

 

Remarks

 

 

Requirements

 

Header:

          sliceO_include.hpp

 

Library:

          sliceO_Structures.lib

 

 

Example

 

// ----------------------------------------------------------------------------

//

//          Func:    Morpho_Fct_Thread()

//

// ----------------------------------------------------------------------------

static          unsigned __stdcall Morpho_Fct_Thread( void *pvoid )

{

SliceO_Window *window =     ((Struct_Dispatch_2 *) pvoid)->window ;

SliceO_Frame *frame =              ((Struct_Dispatch_2 *) pvoid)->frame ;

void              *progress =              ((Struct_Dispatch_2 *) pvoid)->progress ;

 

          Error_Fct( hwnd, ERROR_CODE_TRACE_3, "in Morpho_Fct_Thread()" ) ;

 

          if ( Progress_Abort( progress ) )

              goto abort ;

 

          // --- if image is locked: skip ---

          if ( frame->Lock_Get() ) {

              Error_Fct( hwnd, ERROR_CODE_WARNING, "\xF1\005WARNING:\002 image locked!" ) ;

              Error_Fct( hwnd, ERROR_CODE_WARNING, "\xF1\t skipping: \001%s", frame->Name_Get() ) ;

              Progress_Write( progress, "\xF1\005WARNING:\xF0\002 image locked!" ) ;

              Progress_Write( progress, "\002   skipping: \001%s", frame->Name_Get() ) ;

              goto exit ;

          }

 

          // --- Place a lock on this frame ---

          frame->Lock_Set( 1 ) ;

 

          // --- highlight the frame we are working on ---

          frame->Flag_Set_On( CLASS_MODE_THIS, window, CLASS_FLAG_HIGHLIGHT_BLU ) ;

          Fct_Redraw( REDRAW_HIGHLIGHT, window, frame ) ;

 

          // ====================================================================

          // ==================== Local processing ==============================

          // ====================================================================

 

                    ...

 

          // ====================================================================

          // ==================== Cleanup and get out ===========================

          // ====================================================================

exit:

 

          // --- unlock the frame ---

          frame->Lock_Set( -1 ) ;

 

          // --- refresh the graphics ---

          Fct_Redraw( REDRAW_DB_STENCIL, window, frame ) ;

 

abort:

 

          // --- reset the highlight ----

          // Note: this is done outside the critical region, it could be dangerous...

          frame->Flag_Set_Off( CLASS_MODE_THIS, window, CLASS_FLAG_HIGHLIGHT_BLU ) ;

          Fct_Redraw( REDRAW_HIGHLIGHT, window, frame ) ;

 

          // --- signal that we have finished ---

          Fct_Dispatch_End() ;

 

          _endthreadex( 1 ) ;

          return( 1 ) ;

}

 

See also