18.04.2015 Views

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

.NET APPLICATION PROGRAMMING INTERFACE<br />

System.Runtime.InteropServices.Marshal.ReleaseComObject to decrement the reference<br />

count, allowing the application to terminate cleanly. The StyleGallery is one such<br />

object, and the following example documents how to handle references to this<br />

class.<br />

[VB.NET]<br />

Sub Main()<br />

Dim styCls As ESRI.<strong>ArcGIS</strong>.Display.IStyleGallery = New<br />

ESRI.<strong>ArcGIS</strong>.Framework.StyleGalleryClass<br />

' Use the StyleGalleryClass here ...<br />

Release(styCls)<br />

End Sub<br />

Sub Release(ByVal comObj As Object)<br />

Dim refsLeft As Integer = 0<br />

Do<br />

refsLeft = System.Runtime.InteropServices.Marshal.ReleaseComObject(comObj)<br />

Loop While (refsLeft > 0)<br />

End Sub<br />

[C#]<br />

private void MyFunction()<br />

{<br />

ESRI.<strong>ArcGIS</strong>.Display.IStyleGallery styCls = new<br />

ESRI.<strong>ArcGIS</strong>.Framework.StyleGalleryClass() as<br />

ESRI.<strong>ArcGIS</strong>.Display.IStyleGallery;<br />

// Use the StyleGalleryClass here ...<br />

Release(styCls as object);<br />

}<br />

void Release(object comObj)<br />

{<br />

int refsLeft = 0;<br />

do<br />

{<br />

refsLeft = Marshal.ReleaseComObject(comObj);<br />

}<br />

while (refsLeft > 0);<br />

}<br />

This section does not address licensing considerations<br />

and is intended only to illustrate the<br />

possibilities of server application development<br />

using the .NET API. While the <strong>ArcGIS</strong> <strong>Engine</strong><br />

<strong>Developer</strong> Kit can be used to develop applications<br />

that run on single-use computers and that<br />

may or may not leverage ArcSDE-, <strong>ArcGIS</strong><br />

Server-, or ArcIMS-based services, custom<br />

components deployed on a server require an<br />

<strong>ArcGIS</strong> Server license. Contact your ESRI<br />

regional office or international distributor for<br />

more information.<br />

Working with geodatabase cursors in <strong>ArcGIS</strong> Server<br />

Some objects that you can create in a server context may lock or use resources<br />

that the object frees only in its destructor. For example, a geodatabase cursor may<br />

acquire a shared schema lock on a file-based feature class or table on which it is<br />

based or may hold on to an SDE stream.<br />

While the shared schema lock is in place, other applications can continue to query<br />

or update the rows in the table, but they cannot delete the feature class or modify<br />

its schema. In the case of file-based data sources, such as shapefiles, update<br />

cursors acquire an exclusive write lock on the file, which will prevent other<br />

applications from accessing the file for read or write. The effect of these locks is<br />

that the data may be unavailable to other applications until all of the references<br />

on the cursor object are released.<br />

176 • <strong>ArcGIS</strong> <strong>Engine</strong> <strong>Developer</strong> <strong>Guide</strong>

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

Saved successfully!

Ooh no, something went wrong!