IRefresh2.RefreshToDepth Example

 

The following example shows a subroutine that refreshes a passed Servers collection and updates a listbox or combobox with the resulting list of servers.

C# Example

void UpdateServerList(PISDK.PISDK sdk, ComboBox cbServers)
{
   cbServers.Items.Clear();
   PISDKCommon.IRefresh2 iRefr2 = (PISDKCommon.IRefresh2)sdk.Servers;
   iRefr2.RefreshToDepth(0);
   object objSrv;
   foreach (PISDK.Server sv in sdk.Servers)
   {
      objSrv = sv.Name;
      cbServers.Items.Add(objSrv);
   }
   objSrv = sdk.Servers.DefaultServer.Name;
   cbServers.SelectedItem = objSrv;
}

VB6 Example

Private Sub RefreshServersList(srvrs As Servers, list1 As ListBox)
On Error GoTo eh:
   Dim rfr2 As IRefresh2
   Set rfr2 = srvrs
   rfr2.RefreshToDepth 0
   Dim srv As Server
   list1.Clear
   For Each srv In srvrs
      list1.AddItem srv.Name
   Next
Exit Sub
eh:
   MsgBox Err.Description
End Sub

Enabling Operational Intelligence