![]() | Steema Issues DatabaseNote: This database is for bugs and wishes only. For technical support help, if you are a customer please visit our online forums;otherwise you can use StackOverflow. Before using this bug-tracker we recommend a look at this document, Steema Bug Fixing Policy. |
| Summary: | ObjectDisposedException: Cannot access a disposed object | ||
|---|---|---|---|
| Product: | .NET TeeChart | Reporter: | Bill <bill2004158> |
| Component: | iOS | Assignee: | Steema Issue Manager <issuemanager> |
| Status: | RESOLVED FIXED | ||
| Severity: | blocker | CC: | bill2004158, pep |
| Priority: | Highest | ||
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | Phone | ||
| OS: | iOS | ||
| Chart Series: | --- | Delphi / C++ Builder RAD IDE Version: | |
or how about this:
public override void DoInvalidate()
{
Action action = () =>
{
if (Handle != IntPtr.Zero)
{
SetNeedsDisplay();
}
};
if (NSThread.Current.IsMainThread)
{
action();
}
else
{
NSRunLoop.Main.BeginInvokeOnMainThread(action);
}
}
it seems 4.2018.10.17 fixed that issue. https://www.nuget.org/packages/Steema.TeeChart.NET.Xamarin.Forms/4.2018.10.17 already fixed in newer version. |
after I upgrade "TeeChart for Xamarin.Forms 2018 4.2018.05.16" to "TeeChart for Xamarin Forms 2018 4.2018.09.19". I saw this chanages: public virtual void DoInvalidate() { + DispatchQueue.GetGlobalQueue(DispatchQueuePriority.High).DispatchAsync(() => DispatchQueue.MainQueue.DispatchAsync(() => this.SetNeedsDisplay())); this.SetNeedsDisplay(); } I don't know why use DispatchAsync() to call SetNeedsDisplay(). when callback from MainQueue, "this" object maybe already disposed. thus it cause exception in MainThread, and crash the app. System.ObjectDisposedException: Cannot access a disposed object. Object name: 'TChartExt'. at Foundation.NSObject.get_SuperHandle () [0x00012] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.12/src/Xamarin.iOS/Foundation/NSObject2.cs:449 at UIKit.UIView.SetNeedsDisplay () [0x00023] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.12/src/Xamarin.iOS/UIKit/UIView.g.cs:1722 at Steema.TeeChart.TChart.<DoInvalidate>b__145_1 () [0x00000] in <6bf3489dbb0b46c8960fae68f948879a>:0 at CoreFoundation.DispatchQueue.static_dispatcher_to_managed (System.IntPtr context) [0x00038] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.12/src/Xamarin.iOS/CoreFoundation/Dispatch.cs:344 at (wrapper native-to-managed) CoreFoundation.DispatchQueue.static_dispatcher_to_managed(intptr) at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr) at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.12/src/Xamarin.iOS/UIKit/UIApplication.cs:79 at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0002c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.12/src/Xamarin.iOS/UIKit/UIApplication.cs:63 at iOS.Application.Main (System.String[] args) [0x00002] in G:\Projects\Demo\iOS\Main.cs:20 so: 1. why DispatchAsync() twice to call SetNeedsDisplay()? 2. if that is required for some reason, at least we use check "this" is not disposed before call SetNeedDisplay(), such as: if (Handle != IntPtr.Zero) SetNeedsDisplay();