02.05.2014 Views

CoreandServices.book - Ocean - Schlumberger

CoreandServices.book - Ocean - Schlumberger

CoreandServices.book - Ocean - Schlumberger

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CoreSystem Class<br />

SystemStateChanged Event<br />

The <strong>Ocean</strong> Core will send a SystemStateChanged event whenever the state of the<br />

system changes. The SystemStateChanged event reference will contain the current<br />

state of the system.<br />

...<br />

public Hello<strong>Ocean</strong>Module()<br />

{<br />

// Set up event handler for SystemStateChanged<br />

CoreSystem.SystemStateChanged += new<br />

EventHandler(CoreSystem_SystemStateChanged);<br />

}<br />

void CoreSystem_SystemStateChanged(object sender,<br />

SystemStateEventArgs e)<br />

{<br />

...<br />

//Take action if system is in running state<br />

if (e.State.Equals(SystemState.Running))<br />

{<br />

// load a module dynamically<br />

ModuleReferenceCollection col = new ModuleReferenceCollection();<br />

// define module. string is Namespace.TypeName, AssemblyName<br />

string another<strong>Ocean</strong>Module =<br />

"<strong>Ocean</strong>Labs.Hello<strong>Ocean</strong>.Another<strong>Ocean</strong>Module, Hello<strong>Ocean</strong>Module";<br />

}<br />

}<br />

// add module to the system<br />

col.AddModule(another<strong>Ocean</strong>Module);<br />

CoreSystem.AddModules(col, ”MyModuleTrust”);<br />

SynchronizeInvoke Property<br />

The SynchronizeInvoke property provides a way to synchronously or asynchronously<br />

execute a delegate on the main thread of the application. Using ISynchronizeInvoke<br />

will transfer control from a worker thread to the main thread by queuing the worker thread<br />

delegate on the main loop. You should note that, in Petrel, ISynchronizeInvoke is not<br />

3-50 <strong>Ocean</strong> Application Development Framework 2008.1<br />

<strong>Schlumberger</strong> Private

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!