!!Help: Drawing Performance of ArcEngine

Discussion created by doanminthanh on Dec 29, 2012
Latest reply on Dec 31, 2012 by dubravko.antonic-gdi-net-esridist
Hi everyone, I am studying in ArcEngine, and now I have one problem with Geometric  Network here.
Imaging that I have an Enum of  NetEID (IEnumNetEID)type EDGE want to draw to screen.
Then I use IScreenDisplay draw this Enum to screen base on Flow of each Edge.
private void ShowStatusNetEID()
            INetwork m_Network = m_GeometricNetwork.Network;
            IUtilityNetworkGEN m_UtilityNetWorkGEN = m_Network as IUtilityNetworkGEN;
            IEnumNetEID m_EnumNetEID = m_Network.CreateNetBrowser(esriElementType.esriETEdge);
            int EdgeEID = m_EnumNetEID.Next();
#region Color presets
            IRgbColor BlueColor = new RgbColorClass();
            BlueColor.Red = 0;
            BlueColor.Green = 0;
            BlueColor.Blue = 200;

            IRgbColor GreenColor = new RgbColorClass();
            GreenColor.Red = 0;
            GreenColor.Green = 200;
            GreenColor.Blue = 0;

            IRgbColor RedColor = new RgbColorClass();
            RedColor.Red = 200;
            RedColor.Green = 0;
            RedColor.Blue = 0;

            #region m_GreenLineSymbol : LineSymbol with Green Color
            ILineSymbol m_GreenLineSymbol = new SimpleLineSymbolClass();
            m_GreenLineSymbol.Color = GreenColor;
            m_GreenLineSymbol.Width = 2;

            #region m_RedLineSymbol : LineSymbol with Red Color
            ILineSymbol m_RedLineSymbol = new SimpleLineSymbolClass();
            m_RedLineSymbol.Color = RedColor;
            m_RedLineSymbol.Width = 2;

            #region m_BlueLineSymbol : LineSymbol with Blue Color
            ILineSymbol m_BlueLineSymbol = new SimpleLineSymbolClass();
            m_BlueLineSymbol.Color = BlueColor;
            m_BlueLineSymbol.Width = 2;

            IScreenDisplay m_SD = axMapControl1.ActiveView.ScreenDisplay;
            //Draw Status on each Egde EID
            while (EdgeEID != null)
                if (EdgeEID == 0)
                //Green line for Edge has Flow
                if (m_UtilityNetWorkGEN.GetFlowDirection(EdgeEID) == esriFlowDirection.esriFDAgainstFlow || m_UtilityNetWorkGEN.GetFlowDirection(EdgeEID) == esriFlowDirection.esriFDWithFlow)
                    IGeometry m_Geometry = m_GeometricNetwork.get_GeometryForEdgeEID(EdgeEID);
                    m_SD.SetSymbol(m_GreenLineSymbol as ISymbol);
                //Red Line for Edge that Uninitialize flow
                else if (m_UtilityNetWorkGEN.GetFlowDirection(EdgeEID) == esriFlowDirection.esriFDUninitialized) 
                    IGeometry m_Geometry = m_GeometricNetwork.get_GeometryForEdgeEID(EdgeEID);
                    m_SD.StartDrawing(m_SD.hDC, GN_CacheID);
                    m_SD.SetSymbol(m_RedLineSymbol as ISymbol);

                //Blue line for Edge that Indeterminate flow
                else if (m_UtilityNetWorkGEN.GetFlowDirection(EdgeEID) == esriFlowDirection.esriFDIndeterminate)
                    IGeometry m_Geometry = m_GeometricNetwork.get_GeometryForEdgeEID(EdgeEID);
                    m_SD.StartDrawing(m_SD.hDC, GN_CacheID);
                    m_SD.SetSymbol(m_BlueLineSymbol as ISymbol);
                EdgeEID = m_EnumNetEID.Next();

This code working good and fast on an Network within 1000 edges. But with a large network (e.g 3000 edges) it draw very slow.
So can anyone help me some issue here:
1.How to Draw just draw what is invisible on map( i.e data layer not check on TOC or inside the Network but not load on map.)
2. When Panning or Zooming, how can we just draw the specific screen-frame that show on the ScreenDisplay( not drawing all stuff from Cache to screen, just the area that show up on ScreenDisplay)
3.Can we Drawing using MultiThread for faster.