Let's say we have the following scenario:

0. An application has a main form. 
        Let's say this application is named as IRWork.
1. A main form that has a button.
2. When the user clicks the button in the main form,
        it will invoke a module that handles the IR
        communication.
3.  The communication module has a structure including
        following data member:
                IrConnect
                IrIasObject
                IrIasAttribute
                ...
        
        The module has two choices of managing this structure.

        a. When user clicks the button in the main form, an instance
                of of this structure will be dynamically created.  When
                the communication is done, the instance of the structure
                will be destroyed.  That is two say, if the user clicks the
                button ten times, an object with the type of the described
                structure will be created and destroyed ten times.
        b. An instance of the structure will be declared as global variable
that
                is local to the communication module.  No matter how many
time
                the user clicks on the button in the main form, the same
global
                variable will be used for the communication.  That is to
say, when
                the application starts, this variable will exist until the
termination of
                the application.

Assuming the following is the text snapshot of user using this application.
1. User starts IRWork
2. User clicks on the button in the main form couple times
3. User switch to other application
4. User switch back to IRWork
5. User clicks on the button in the main form couple times again.

With this text snapshot, if the communication module chooses 'a' to manage
the
structure, this application will hang at text snapshot #5 while trying to
establish
IR connection with remote device.  However, if the communication module
choose
'b' to manage the structure, the problem won't occur at all.

For both of the options, it makes sense to me.  Therefore, I really don't
know what
is wrong with option 'a'.  Any information that explains what is wrong with
option 'a'
or how the IR actually works will be greatly appreciated.  Thanks.

Walter

Reply via email to