Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
It appears you're not allowing NSMutableParagraphStyle to be run on a background thread and throwing a EnsureUIThread on this usage. Are you sure this is correct per iOS? As far as I can tell it should not require a UI thread.
at UIKit.UIApplication.EnsureUIThread () [0x00023] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:70
at UIKit.NSMutableParagraphStyle.set_Alignment (UITextAlignment value) [0x00000] in /Developer/MonoTouch/Source/monotouch/src/build/native/UIKit/NSMutableParagraphStyle.g.cs:105
at apdl.WhatIfGenerator.generatePDF_Page (apdl.MyContextPDF context, System.String dayPreview, Single fontSize) [0x00075] in /Users/Neal/Dev/ncsoftware/APDL/APDL.iOS/ReusableViewControllers/ReportGenerator.cs:971
at apdl.WhatIfGenerator+<GenerateIPhone>c__AnonStorey0.<>m__0 () [0x00032] in /Users/Neal/Dev/ncsoftware/APDL/APDL.iOS/ReusableViewControllers/ReportGenerator.cs:359
at ObjCRuntime.Trampolines+SDAction.Invoke (IntPtr block) [0x00019] in /Developer/MonoTouch/Source/monotouch/src/build/native/ObjCRuntime/Trampolines.g.cs:251
at (wrapper native-to-managed) ObjCRuntime.Trampolines/SDAction:Invoke (intptr)
at (wrapper managed-to-native) ObjCRuntime.Messaging:void_objc_msgSendSuper_IntPtr (intptr,intptr,intptr)
at CoreData.NSManagedObjectContext.PerformAndWait (System.Action action) [0x00054] in /Developer/MonoTouch/Source/monotouch/src/build/native/CoreData/NSManagedObjectContext.g.cs:356
at apdl.WhatIfGenerator.GenerateIPhone (System.String filename, apdl.Day day, apdl.Overrides overrides, System.Collections.Generic.List`1 results) [0x00041] in /Users/Neal/Dev/ncsoftware/APDL/APDL.iOS/ReusableViewControllers/ReportGenerator.cs:348
at apdl.LegalityDetailTableViewController.<ViewDidLoad>m__1D () [0x00069] in /Users/Neal/Dev/ncsoftware/APDL/APDL.iOS/Legality/LegalityTableViewController.cs:405
at apdl.PDFPageTurnViewController.<createDocumentAsync>m__0 () [0x00018] in /Users/Neal/Dev/ncsoftware/APDL/APDL.iOS/ReusableViewControllers/PDF/PDFPageTurnViewController.cs:166
at System.Threading.Tasks.TaskActionInvoker+ActionInvoke.Invoke (System.Threading.Tasks.Task owner, System.Object state, System.Threading.Tasks.Task context) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Threading.Tasks/TaskActionInvoker.cs:71
at System.Threading.Tasks.Task.InnerInvoke () [0x00031] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Threading.Tasks/Task.cs:548
at System.Threading.Tasks.Task.ThreadStart () [0x000d0] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Threading.Tasks/Task.cs:438
(In reply to comment #0)
> As far as I can tell it should not require a UI thread.
Did you find any official documentation about it?
The Apple documentation we've found state that "For the most part, use UIKit classes only from your app’s main thread. This is particularly true for classes derived from UIResponder or that involve manipulating your app’s user interface in any way." 
NSMutableParagraphStyle doesn't derive from UIResponder, but it's still a UIKit class, which means that we've defaulted to only allow it on the main thread (and the documentation for NSMutableParagraphStyle doesn't say anything to the contrary).
Our opinion is it should not require a UI thread such as for generating PDF reports in the background, etc. but I don't have any official documentation to share other than what you offered. I think the assumption being more restrictive can be problematic in a case such as this, just my $.02.
@Sebastien, what do you think about this? IMHO NSMutableParagraphStyle doesn't sound like something that should be problematic in background threads, so it'll probably be safe.
@Rolf Bjarne Kvinge
1. NSAttributedString is thread safe. And NSMutableParagraphStyle is the parameter of UIStringAttributes to initialise NSAttributedString. So ...
About NSAttributeString and Thread safe, please visit
2. Call NSMutableParagraphStyle in background thread using swift language, no problem - I think Xamarin will supports the features really work, not to support the features with official document
Please help to fix them earlier.
Discussed with Sebastien, the change for this should be making C6.
Fixed in maccore / master 2c6a5303a71a897d216de4666ede24cf31a2b335