public override global::System.Object calcPreferredSize() { int w = 0; int h = 0; SilverlightImplementation.dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { element.Measure(new Size(1000000, 1000000)); w = SilverlightImplementation.screen.ConvertDipsToPixels((float)(element.DesiredSize.Width * SilverlightImplementation.scaleFactor), CanvasDpiRounding.Round); h = SilverlightImplementation.screen.ConvertDipsToPixels((float)(element.DesiredSize.Height * SilverlightImplementation.scaleFactor), CanvasDpiRounding.Round); }).AsTask().ConfigureAwait(false).GetAwaiter().GetResult(); com.codename1.ui.geom.Dimension d = new com.codename1.ui.geom.Dimension(); d.@this(Math.Max(2, w), Math.Max(2, h)); return d; }
public override global::System.Object calcPreferredSize() { int w = 0; int h = 0; using (AutoResetEvent are = new AutoResetEvent(false)) { System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() => { element.Measure(new Size(1000000, 1000000)); w = (int)element.DesiredSize.Width; h = (int)element.DesiredSize.Height; are.Set(); }); are.WaitOne(); } com.codename1.ui.geom.Dimension d = new com.codename1.ui.geom.Dimension(); d.@this(Math.Max(2, w), Math.Max(2, h)); return d; }