HOW TO
The IFeatureProgress and IReplicaProgress interfaces define properties that are not accessible through the .NET interop assembly 'event' interfaces. Instructions provided describe how to create helper classes as a workaround for this limitation.
Note:
To successfully compile the code shown in this article, the following assemblies must be referenced by the solution, and 'using' statements must be added for their corresponding namespaces:
- ESRI.ArcGIS.Display
- ESRI.ArcGIS.Geodatabase
- ESRI.ArcGIS.GeoDatabaseDistributed
- ESRI.ArcGIS.Server
- ESRI.ArcGIS.System
Code:
private class FeatureProgressHelper : IFeatureProgress
{
private int featureCount = 0;
private int stepValue = 0;
String IFeatureProgress.FeatureClassName
{
set { Console.WriteLine("FeatureClassName: {0}", value); }
}
Boolean IFeatureProgress.IsCancelled
{
get { return false; }
}
int IFeatureProgress.MaxFeatures
{
set { Console.WriteLine("MaxFeatures: {0}", value); }
}
int IFeatureProgress.MinFeatures
{
set { Console.WriteLine("MinFeatures: {0}", value); }
}
int IFeatureProgress.Position
{
set { Console.WriteLine("Position: {0}", value); }
}
void IFeatureProgress.Step()
{
// Increment the number of features replicated and display the progress.
featureCount += stepValue;
Console.WriteLine("{0} features replicated.", featureCount);
}
int IFeatureProgress.StepValue
{
set { stepValue = value; }
}
}
Code:
public FeatureProgressHelper(IConnectionPointContainer connectionPointContainer)
{
// Get the event source's connection points.
IEnumConnectionPoints enumConnectionPoints = null;
connectionPointContainer.EnumConnectionPoints(out enumConnectionPoints);
enumConnectionPoints.Reset();
// Iterate through the connection points until one for IFeatureProgress is found.
IConnectionPoint connectionPoint = null;
Guid featureProgressGuid = typeof(IFeatureProgress).GUID;
uint pcFetched = 0;
enumConnectionPoints.RemoteNext(1, out connectionPoint, out pcFetched);
while (connectionPoint != null)
{
Guid connectionInterfaceGuid;
connectionPoint.GetConnectionInterface(out connectionInterfaceGuid);
if (connectionInterfaceGuid == featureProgressGuid)
{
break;
}
enumConnectionPoints.RemoteNext(1, out connectionPoint, out pcFetched);
}
// If IFeatureProgress wasn't found, throw an exception.
if (connectionPoint == null)
{
throw new ArgumentException("An IFeatureProgress connection point could not be found.");
}
// Tie into the connection point.
uint connectionPointCookie = 0;
connectionPoint.Advise(this, out connectionPointCookie);
}
Note:
The following example uses the ReplicationAgent class. Prior to the 9.3 release, ReplicationAgent did not implement IConnectionPointContainer, meaning that this code fails at run time.
Code:
IReplicationAgent replicationAgent = new ReplicationAgentClass();
IConnectionPointContainer connectionPointContainer = (IConnectionPointContainer)replicationAgent;
FeatureProgressHelper featureProgressHelper = new FeatureProgressHelper(connectionPointContainer);
// Create the replica...
Get help from ArcGIS experts
Download the Esri Support App