- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
I'm trying to call some API methods in an asynchronous way, but when running my program, the Inventor is getting slower, and I also detect high CPU usage.
Thank you !!
TextGraphics textGraphics = null;
GraphicsNode oGraphicNode;
static void CreateTextGraphic(GraphicsNode oGraphicNode, string Text)
{
DeleteClientGraphicPrimitive();
if (textGraphics != null)
{
textGraphics.Delete();
}
Point Origin = oApp.TransientGeometry.CreatePoint(0, 0, 0);
Point2d AnchoredPoint = oApp.TransientGeometry.CreatePoint2d(100, 0);
//Create text graphics.
textGraphics = oGraphicNode.AddTextGraphics();
textGraphics.Text = Text;
textGraphics.SetViewSpaceAnchor(Origin, AnchoredPoint, ViewLayoutEnum.kTopLeftViewCorner); ;
textGraphics.SetTransformBehavior(Origin, DisplayTransformBehaviorEnum.kFrontFacingAndPixelScaling, 100);
oApp.ActiveView.Update();
}
static async Task UpdateTextGraphics()
{
int i = 0;
try
{
do
{
await Task.Run(() => CreateTextGraphic(oGraphicNode,i.ToString()));
i++;
} while (true);
}
catch (OperationCanceledException)
{
Console.WriteLine($"\n{nameof(OperationCanceledException)} thrown\n");
}
}
Solved! Go to Solution.