# InMemoryFeatureLayer refresh without use winformmap.refresh() method

**URL:** <https://community.thinkgeo.com/t/inmemoryfeaturelayer-refresh-without-use-winformmap-refresh-method/8906>\
**Category:** WinForms\
**Created:** [February 1, 2018, 2:44am UTC](https://community.thinkgeo.com/t/inmemoryfeaturelayer-refresh-without-use-winformmap-refresh-method/8906 "2018-02-01T02:44:23Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tamil\_Arasan](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/tamil_arasan/32/20780_2.png) [@Tamil\_Arasan](https://community.thinkgeo.com/u/Tamil_Arasan)\
**Post date:** [February 1, 2018, 2:44am UTC](https://community.thinkgeo.com/t/inmemoryfeaturelayer-refresh-without-use-winformmap-refresh-method/8906/1 "2018-02-01T02:44:24Z")

</div>

Hi Team,

Any possible to refresh dynamic added feature without use winformmap.refresh() method.

**Feature add ,update and remove it call from background thread process.**

Regrads,  
Tamilarasan.

---

<div class="post-metadata">

**Author:** ![Ethan](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/ethan/32/19964_2.png) [@Ethan](https://community.thinkgeo.com/u/Ethan)\
**Post date:** [February 1, 2018, 10:09am UTC](https://community.thinkgeo.com/t/inmemoryfeaturelayer-refresh-without-use-winformmap-refresh-method/8906/2 "2018-02-01T10:09:51Z")

</div>

Hi Tamilarasan,

If your layer number is big, you can put the dynamic layer into a separate overlay, and only refresh this overlay when necessary.

Wish that’s helpful.

Regards,

Ethan

---

<div class="post-metadata">

**Author:** ![Tamil\_Arasan](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/tamil_arasan/32/20780_2.png) [@Tamil\_Arasan](https://community.thinkgeo.com/u/Tamil_Arasan)\
**Post date:** [February 2, 2018, 4:13am UTC](https://community.thinkgeo.com/t/inmemoryfeaturelayer-refresh-without-use-winformmap-refresh-method/8906/3 "2018-02-02T04:13:24Z")

</div>

Hi Ethan,’

Good Morning,

Please share any sample on only refresh Overlay in map suite desktop edition

Regards,  
Tamilarasan.

---

<div class="post-metadata">

**Author:** ![Ethan](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/ethan/32/19964_2.png) [@Ethan](https://community.thinkgeo.com/u/Ethan)\
**Post date:** [February 2, 2018, 7:54am UTC](https://community.thinkgeo.com/t/inmemoryfeaturelayer-refresh-without-use-winformmap-refresh-method/8906/4 "2018-02-02T07:54:56Z")

</div>

Hi Tamilarasan,

You can directly call the LayerOverlay.Refresh(), which can only refresh one overlay.

Regards,

Ethan

---

<div class="post-metadata">

**Author:** ![Tamil\_Arasan](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/tamil_arasan/32/20780_2.png) [@Tamil\_Arasan](https://community.thinkgeo.com/u/Tamil_Arasan)\
**Post date:** [February 3, 2018, 2:39am UTC](https://community.thinkgeo.com/t/inmemoryfeaturelayer-refresh-without-use-winformmap-refresh-method/8906/5 "2018-02-03T02:39:03Z")

</div>

Hi Ethan,

We try but LayerOverlay.Refresh(GeoCanvas,Rectangle) method only available in map suite winform desktop version

**I want know how to pass those parameter for this LayerOverlay.Refresh(GeoCanvas,Rectangle)**

Regards,

Tamilarasan.

---

<div class="post-metadata">

**Author:** ![Ethan](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/ethan/32/19964_2.png) [@Ethan](https://community.thinkgeo.com/u/Ethan)\
**Post date:** [February 5, 2018, 7:52am UTC](https://community.thinkgeo.com/t/inmemoryfeaturelayer-refresh-without-use-winformmap-refresh-method/8906/6 "2018-02-05T07:52:27Z")

</div>

Hi Tamilarasan,

It looks the LayerOverlay.Refresh() is a little complex for this scenario, please just ignore that and use this API instead of it, it can refresh specified overlay.

winformsMap1.Refresh(layerOverlay);

Regards,

Ethan

---

<div class="post-metadata">

**Author:** ![Tamil\_Arasan](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/tamil_arasan/32/20780_2.png) [@Tamil\_Arasan](https://community.thinkgeo.com/u/Tamil_Arasan)\
**Post date:** [February 5, 2018, 2:57pm UTC](https://community.thinkgeo.com/t/inmemoryfeaturelayer-refresh-without-use-winformmap-refresh-method/8906/7 "2018-02-05T14:57:35Z")

</div>

Hi Ethan,

I try to Implement pointOverlay.AutoRefreshInterval = TimeSpan.FromMilliseconds(1000); but it cause some exception when close my current winform .

**Fatal Thread System.NullReferenceException: Object reference not set to an instance of an object.**  
**at ThinkGeo.MapSuite.WinForms.WinformsMap.PFM=(Graphics graphics, RectangleShape extent)**  
**at ThinkGeo.MapSuite.WinForms.WinformsMap.GlM=(RectangleShape drawingExtent, RectangleShape extent)**  
**at ThinkGeo.MapSuite.WinForms.WinformsMap.OVM=(RectangleShape extent)**  
**at ThinkGeo.MapSuite.WinForms.WinformsMap.gRU=(Int32 delayInterval, RectangleShape extent)**  
**at ThinkGeo.MapSuite.WinForms.WinformsMap.Refresh(RectangleShape extent, IEnumerable`1 overlays)** **at ThinkGeo.MapSuite.WinForms.WinformsMap./RU=(IEnumerable`1 extentsToRefresh, IEnumerable`1 overlays)** **at ThinkGeo.MapSuite.WinForms.WinformsMap.ixo=.kxo=()** **at ThinkGeo.MapSuite.WinForms.WinformsMap.ixo=.kho=(AVQ= parameter, RequestDrawingBufferTimeType bufferTimeType)** **at ThinkGeo.MapSuite.WinForms.WinformsMap.EVM=(Object sender, RequestedDrawingOverlayEventArgs e)** **at ThinkGeo.MapSuite.WinForms.Overlay.OnRequestedDrawing(RequestedDrawingOverlayEventArgs eventArgs)** **at ThinkGeo.MapSuite.WinForms.Overlay.eCU=(IEnumerable`1 extentsToRefresh, TimeSpan bufferTime, RequestDrawingBufferTimeType bufferTimeType)**  
**at ThinkGeo.MapSuite.WinForms.Overlay.RequestDrawing()**  
**at ThinkGeo.MapSuite.WinForms.Overlay.b\_\_88\_0(Object , EventArgs )**  
**at System.Windows.Forms.Timer.OnTick(EventArgs e)**  
**at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)**  
**at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)**

Regards,  
Tamilarasan.

---

<div class="post-metadata">

**Author:** ![Ethan](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/ethan/32/19964_2.png) [@Ethan](https://community.thinkgeo.com/u/Ethan)\
**Post date:** [February 6, 2018, 8:01am UTC](https://community.thinkgeo.com/t/inmemoryfeaturelayer-refresh-without-use-winformmap-refresh-method/8906/8 "2018-02-06T08:01:12Z")

</div>

Hi Tamilarasan,

I tried to set the layerOverlay.AutoRefreshInterval = TimeSpan.FromMilliseconds(1000), it works well.

Please show us your code or upload a simple sample, so we can see what’s the problem.

Regards,

Ethan

---

<div class="post-metadata">

**Author:** ![Tamil\_Arasan](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/tamil_arasan/32/20780_2.png) [@Tamil\_Arasan](https://community.thinkgeo.com/u/Tamil_Arasan)\
**Post date:** [February 6, 2018, 9:59am UTC](https://community.thinkgeo.com/t/inmemoryfeaturelayer-refresh-without-use-winformmap-refresh-method/8906/9 "2018-02-06T09:59:33Z")

</div>

Hi Ethan,

Here attach my sample code.  
InMemoryFeatureLayer pointLayer = new InMemoryFeatureLayer();  
pointLayer.Open();  
TextStyle txtStyle = new TextStyle(“UnitNbr”, new GeoFont(“Arial”, 9), new GeoSolidBrush(new GeoColor(0, 0, 0)));  
txtStyle.YOffsetInPixel = 22;  
txtStyle.XOffsetInPixel = -15;  
txtStyle.MaskType = MaskType.RoundedCorners;  
txtStyle.MaskMargin = 1;  
txtStyle.Mask = new AreaStyle(new GeoPen(GeoColor.FromArgb(10, 204, 204, 204), 1),  
new GeoSolidBrush(GeoColor.FromArgb(10, 75, 75, 0)));

```
        pointLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(txtStyle);

        pointLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

        pointOverlay = new LayerOverlay();
        pointOverlay.Layers.Add("PHX_PointLayer", pointLayer);
        ctrlThinkGEOMap.Overlays.Add("PointOverlay", pointOverlay);
        collMapLayers.Add(pointLayer);

        pointOverlay.AutoRefreshInterval = TimeSpan.FromMilliseconds(1000);

```

Regards,  
Tamilarasan.

---

<div class="post-metadata">

**Author:** ![Ethan](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/ethan/32/19964_2.png) [@Ethan](https://community.thinkgeo.com/u/Ethan)\
**Post date:** [February 7, 2018, 6:31am UTC](https://community.thinkgeo.com/t/inmemoryfeaturelayer-refresh-without-use-winformmap-refresh-method/8906/10 "2018-02-07T06:31:43Z")

</div>

Hi Tamilarasan,

We still cannot reproduce this issue you reported, we created a sample based on your code here: [8906.zip](https://community.thinkgeo.com/uploads/default/original/3X/9/a/9aabf0cee64dfa37beae7e00aa13247528288595.zip) (102.4 KB)

Please download it and run it, then modify the code to reproduce your issue, so our developer can look into it and solve it.

Regards,

Ethan

---

<div class="post-metadata">

**Author:** ![Tamil\_Arasan](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/tamil_arasan/32/20780_2.png) [@Tamil\_Arasan](https://community.thinkgeo.com/u/Tamil_Arasan)\
**Post date:** [February 7, 2018, 7:18am UTC](https://community.thinkgeo.com/t/inmemoryfeaturelayer-refresh-without-use-winformmap-refresh-method/8906/11 "2018-02-07T07:18:26Z")

</div>

Hi Ethan,

I attached the updated code, Please run the solution if click map menu and close the mdi child window it cause the exception.

Please refer below screen shot

 ![](https://community.thinkgeo.com/uploads/default/original/3X/5/8/58d639f800d44dbd1d0a8132867688d9237e77d1.png)

 ![](https://community.thinkgeo.com/uploads/default/original/3X/6/8/68d565b991bd5352efa04ed974be1444e0285246.png)

Thanks,  
Tamilarasan.Uploading…

---

<div class="post-metadata">

**Author:** ![Ethan](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/ethan/32/19964_2.png) [@Ethan](https://community.thinkgeo.com/u/Ethan)\
**Post date:** [February 7, 2018, 7:58am UTC](https://community.thinkgeo.com/t/inmemoryfeaturelayer-refresh-without-use-winformmap-refresh-method/8906/12 "2018-02-07T07:58:56Z")

</div>

Hi Tamilarasan,

It looks you failed to upload that, please upload it again.

Regards,

Ethan

---

<div class="post-metadata">

**Author:** ![Tamil\_Arasan](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/tamil_arasan/32/20780_2.png) [@Tamil\_Arasan](https://community.thinkgeo.com/u/Tamil_Arasan)\
**Post date:** [February 12, 2018, 6:29am UTC](https://community.thinkgeo.com/t/inmemoryfeaturelayer-refresh-without-use-winformmap-refresh-method/8906/13 "2018-02-12T06:29:47Z")

</div>

Hi Ethan,

Here attached latest file .

Regards,  
Tamilarasan.[Overlay.zip](https://community.thinkgeo.com/uploads/default/original/3X/6/4/64c68f0504c6a40a9ec7b44438281ce3bceaee96.zip) (2.4 MB)

---

<div class="post-metadata">

**Author:** ![Ethan](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/ethan/32/19964_2.png) [@Ethan](https://community.thinkgeo.com/u/Ethan)\
**Post date:** [February 12, 2018, 9:40am UTC](https://community.thinkgeo.com/t/inmemoryfeaturelayer-refresh-without-use-winformmap-refresh-method/8906/14 "2018-02-12T09:40:53Z")

</div>

Hi Tamilarasan,

Thanks for your project, please see the solution as below. I have let our developer know it and they will do enhancement for this API, but it won’t be changed now because it’s related with the structure.

```
        private void Form1_Load(object sender, EventArgs e)
    {
        this.FormClosed += Form1_FormClosed;

        winformsMap1.MapUnit = GeographyUnit.DecimalDegree;            

        InMemoryFeatureLayer pointLayer = new InMemoryFeatureLayer();
        pointLayer.Open();
        TextStyle txtStyle = new TextStyle("UnitNbr", new GeoFont("Arial", 9), new GeoSolidBrush(new GeoColor(0, 0, 0)));
        txtStyle.YOffsetInPixel = 22;
        txtStyle.XOffsetInPixel = -15;
        txtStyle.MaskType = MaskType.RoundedCorners;
        txtStyle.MaskMargin = 1;
        txtStyle.Mask = new AreaStyle(new GeoPen(GeoColor.FromArgb(10, 204, 204, 204), 1),
        new GeoSolidBrush(GeoColor.FromArgb(10, 75, 75, 0)));

        pointLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(txtStyle);

        pointLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

        LayerOverlay pointOverlay = new LayerOverlay();
        pointOverlay.Layers.Add("PHX_PointLayer", pointLayer);
        winformsMap1.Overlays.Add("PointOverlay", pointOverlay);            

        pointOverlay.AutoRefreshInterval = TimeSpan.FromMilliseconds(1000);

        winformsMap1.Refresh(pointOverlay);
    }

    private void Form1_FormClosed(object sender, FormClosedEventArgs e)
    {
        LayerOverlay pointOverlay = winformsMap1.Overlays["PointOverlay"] as LayerOverlay;
        pointOverlay.AutoRefreshInterval = TimeSpan.FromMilliseconds(0);            
    }

```

Thanks to let us know that and wish that’s helpful.

Regards,

Ethan

---

<div class="post-metadata">

**Author:** ![Tamil\_Arasan](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/tamil_arasan/32/20780_2.png) [@Tamil\_Arasan](https://community.thinkgeo.com/u/Tamil_Arasan)\
**Post date:** [February 13, 2018, 10:47am UTC](https://community.thinkgeo.com/t/inmemoryfeaturelayer-refresh-without-use-winformmap-refresh-method/8906/15 "2018-02-13T10:47:01Z")

</div>

Hi Ethan,

It help, Thanks.

Regards,  
Tamilarasan.

---

<div class="post-metadata">

**Author:** ![Ethan](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/ethan/32/19964_2.png) [@Ethan](https://community.thinkgeo.com/u/Ethan)\
**Post date:** [February 14, 2018, 1:17am UTC](https://community.thinkgeo.com/t/inmemoryfeaturelayer-refresh-without-use-winformmap-refresh-method/8906/16 "2018-02-14T01:17:58Z")

</div>

Hi Tamilarasan,

I am glad to hear that’s helpful.

Any question please let us know.

Regards,

Ethan
