Cisco Cisco Computer Telephony Integration Option 8.5 Developer's Guide

Page of 546
 
12-13
Cisco ICM Software CTI OS Developer’s Guide Release 6.0(0)
 
Chapter 12      Helper Classes
Arguments Class
Usage Notes
When writing an application using the CTI OS SDK, the following sequence of 
steps in the program may produce a problem:
Programmer passes an Arguments array into a CTI OS SDK method 
(methodA)
MethodA returns
Programmer modifies the same Arguments array
Programmer passes the modified Arguments array into another CTI OS SDK 
method (methodB)
When running the application, the call to methodA may behave as if it was passed 
the modified Arguments array. This is because many CTI OS methods simply 
place a pointer to the Arguments array on a queue of items to be sent to CTI OS 
server. When the same Arguments array is later modified, as in the preceding 
example, the pointer on the queue now points to the modified array and the 
modified array is sent to CTI OS server. A problem may occur depending on 
timing, as there are multiple threads involved: the thread pulling items off the 
queue and the thread modifying the Arguments array. If the queued message is 
sent to CTI OS before the Arguments array is modified, the problem will not 
occur.
To avoid this problem, call the Clone method on the initial Arguments array and 
modify the copy rather than modifying the original. For example, the preceding 
example would change as follows:
Programmer passes an Arguments array (initialArray) into a CTI OS SDK 
method (methodA)
MethodA returns
modifiedArray = initialArray.Clone()
Programmer modifies modifiedArray
Programmer passes the modifiedArray into another CTI OS SDK method 
(methodB)