Hi,
Getting exception in multithreaded/parallel sync app.
We sync parallelly/multithread all Hardware and Camera properties(Camera Tabs), Storage, Speakers, Output, etc.. between two recording server.
We get exception for Microphone Events, Camera Events, Input Events - “Device configuration was updated outside of Configuration API. Refresh the configuration and try again.”
/*Pseudo Code*/
We have two recording server on single management server having same Cameras
{
Rec1 = ["Cam1", "Cam2", "Cam3"];
Rec2 = ["Cam1", "Cam2", "Cam3"];
camlisttosync = ["Cam1", "Cam2", "Cam3", ...] ;
Thread[] thd = new Thread(total);
thd[0] = new ThreadStart(syncfunction(camlisttosync[0]));
thd[1] = new ThreadStart(syncfunction(camlisttosync[1]));
thd[2] = new ThreadStart(syncfunction(camlisttosync[2]));
....
thd[n] = new ThreadStart(syncfunction(camlisttosync[n]));
wait for all thread to finish
WaitAllThread(thd);
}
void syncfunction(String CameraName)
{
Hardware PrimHw = findHW(Rec1, CameraName);
Hardware SecHW = findHW(Rec2, CameraName);
syncHardwareproperties(PrimHw, SecHW);
syncSpeakerproperties(PrimHw, SecHW);
syncOutputproperties(PrimHw, SecHW);
syncInputproperties(PrimHw, SecHW);
}
void syncInputproperties(Hardware PrimHw, Hardware SecHW)
{
InputEvent PrimInput = PrimHw.InputEventFolder.InputEvents.SingleOrDefault(x => x.Channel == 0);
InputEvent SecInput = SecHW.InputEventFolder.InputEvents.SingleOrDefault(x => x.Channel == 0);
try
{
HardwareDeviceEventFolder PrimHDEF = PrimInput.HardwareDeviceEventFolder;
if (PrimHDEF != null)
{
foreach (HardwareDeviceEvent PrimHDE in PrimHDEF.HardwareDeviceEvents)
{
HardwareDeviceEvent SecHDE = null;
SecHDE = SecInput.HardwareDeviceEventFolder.HardwareDeviceEvents.SingleOrDefault(x => x.DisplayName == PrimHDE.DisplayName);
if (SecHDE != null)
{
int iIndex = 0;
foreach (HardwareDeviceEventChildItem PrimHDECI in PrimHDE.HardwareDeviceEventChildItems)
{
HardwareDeviceEventChildItem SecHDECI = SecHDE.HardwareDeviceEventChildItems.ElementAt(iIndex++);
if (SecHDECI != null)
{
SecHDECI.Name = PrimHDECI.Name;
SecHDECI.Enabled = PrimHDECI.Enabled;
SecHDECI.Description = PrimHDECI.Description;
SecHDECI.EventUsed = PrimHDECI.EventUsed;
SecHDECI.EventIndex = PrimHDECI.EventIndex;
}
}
}
// Saving the modified changes
SecHDE.Save(); //exception here "Device configuration was updated outside of Configuration API. Refresh the configuration and try again."
}
}
}
catch (Exception exp)
{
}
try
{
// Saving changes
SecInput.Save();
}
catch (Exception exp)
{
}
}
/*Pseudo Code*/
Thanks,
Vega Support