Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1369
Ultra TabControll
posted

Hi,

I am using to UltraTabControl 6.3. I want to blink the tab when query executed sucessfully. Here is the code. Exception occurs when control backcolor changes. Due to this red X appears on tabconrol.

  private void BlinkTab()
        {
            try
            {
                if (UltraTab != null)
                {
                    Monitor.Enter(UltraTab);
                    {
                        bool blnIsOriginal = true;

                        while (!UltraTab.Selected && !this.IsDisposed)
                        {
                            try
                            {
                                if (blnIsOriginal)
                                {
                                    UltraTab.Appearance.BackColor = System.Drawing.SystemColors.ActiveCaption;
                                    UltraTab.Appearance.BackColor2 = System.Drawing.SystemColors.GradientInactiveCaption;
                                    blnIsOriginal = false;
                                    Thread.Sleep(500);
                                }
                                else
                                {
                                    blnIsOriginal = true;
                                    UltraTab.Appearance.BackColor = Color.Empty;
                                    UltraTab.Appearance.BackColor2 = Color.Empty;
                                    Thread.Sleep(500);
                                }
                            }
                            catch (Exception ex)
                            {
                                Console.Write("Exception in blinking.");
                            }
                        }
                        UltraTab.Appearance.BackColor = Color.Empty;

                    }
                }
            }
            catch (Exception ex)
            {
                BlinkTab();
            }
            finally
            {
                Monitor.Exit(UltraTab);
            }
        }
        private void BlinkEvent(UltraTab pulUltraTab)
        {
            _mUltraTab = pulUltraTab;
            Thread objThreadBlinkTab = new Thread(new ThreadStart(BlinkTab));
            objThreadBlinkTab.Start();
        }

But when I run the multiple queries and wait for minutes it is giving error object reference is not instance of that object on changing the color backcolor. I am having each tab in seperate object and this function is private.

Here is exception it changes every time

System.NullReferenceException occurred
  Message="Object reference not set to an instance of an object."
  Source="Infragistics2.Win.v6.3"
  StackTrace:
       at Infragistics.Win.UIElement.GetDescendant(Type type, Object[] contexts)
       at Infragistics.Win.UIElement.GetDescendant(Type type, Object context)
       at Infragistics.Win.UltraWinTabs.TabManager.GetUIElement(ITabItem tab)
       at Infragistics.Win.UltraWinTabs.TabManager.DirtyTabItem(ITabItem tab, Boolean invalidate, Boolean dirtyTextMetrics, Boolean dirtyImageMetrics)
       at Infragistics.Win.UltraWinTabControl.UltraTabsCollection.OnSubObjectPropChanged(PropChangeInfo propChangeInfo)
       at Infragistics.Shared.SubObjectBase.NotifyPropChange(PropChangeInfo trigger)
       at Infragistics.Shared.SubObjectBase.NotifyPropChange(Enum propId, PropChangeInfo trigger)
       at Infragistics.Win.UltraWinTabControl.UltraTab.OnSubObjectPropChanged(PropChangeInfo propChangeInfo)
       at Infragistics.Win.AppearanceHolder.OnSubObjectPropChanged(PropChangeInfo propChange)
       at Infragistics.Shared.SubObjectBase.NotifyPropChange(PropChangeInfo trigger)
       at Infragistics.Shared.SubObjectBase.NotifyPropChange(Enum propId)
       at Infragistics.Win.AppearanceData.set_BackColor2(Color value)
       at Infragistics.Win.Appearance.set_BackColor2(Color value)
       at Thomson.Financial.Framework.Data.MarketQA.MarketQAClient.BlinkTab() in D:\SVN\Branches\.....\..\Client.cs:line 1273


System.NullReferenceException occurred
  Message="Object reference not set to an instance of an object."
  Source="Infragistics2.Win.UltraWinTabControl.v6.3"
  StackTrace:
       at Infragistics.Win.UltraWinTabControl.UltraTabControlBase.get_StyleResolved()
       at Infragistics.Win.UltraWinTabControl.UltraTabControlBase.TabControlTabProvider.Infragistics.Win.UltraWinTabs.ITabProvider.get_Style()
       at Infragistics.Win.UltraWinTabs.TabManager.get_StyleResolved()
       at Infragistics.Win.UltraWinTabs.TabManager.get_InterTabSpacingResolved()
       at Infragistics.Win.UltraWinTabs.TabManager.InitializeFirstDisplayedTabItem(ITabItem tab, ScrollType scrollType, Int32 scrollIncrement, Boolean fireScrollEvents)
       at Infragistics.Win.UltraWinTabs.TabManager.VerifyFirstDisplayedTabItem()
       at Infragistics.Win.UltraWinTabs.TabManager.get_FirstDisplayedTabItem()
       at Infragistics.Win.UltraWinTabs.TabManager.IsTabItemInView(ITabItem tab, Boolean excludePartiallyInView)
       at Infragistics.Win.UltraWinTabs.TabManager.GetUIElement(ITabItem tab)
       at Infragistics.Win.UltraWinTabs.TabManager.DirtyTabItem(ITabItem tab, Boolean invalidate, Boolean dirtyTextMetrics, Boolean dirtyImageMetrics)
       at Infragistics.Win.UltraWinTabControl.UltraTabsCollection.OnSubObjectPropChanged(PropChangeInfo propChangeInfo)
       at Infragistics.Shared.SubObjectBase.NotifyPropChange(PropChangeInfo trigger)
       at Infragistics.Shared.SubObjectBase.NotifyPropChange(Enum propId, PropChangeInfo trigger)
       at Infragistics.Win.UltraWinTabControl.UltraTab.OnSubObjectPropChanged(PropChangeInfo propChangeInfo)
       at Infragistics.Win.AppearanceHolder.OnSubObjectPropChanged(PropChangeInfo propChange)
       at Infragistics.Shared.SubObjectBase.NotifyPropChange(PropChangeInfo trigger)
       at Infragistics.Shared.SubObjectBase.NotifyPropChange(Enum propId)
       at Infragistics.Win.AppearanceData.set_BackColor2(Color value)
       at Infragistics.Win.Appearance.set_BackColor2(Color value)
       at Thomson.Financial.Framework.Data.MarketQA.MarketQAClient.BlinkTab() in D:\SVN\Branches\.....\..\Client.cs: line 1273

Parents
  • 37774
    Suggested Answer
    posted

    It seems like you're updating the tab on a thread outside of the UI thread.  This is not a safe thing to do in .NET, since you could cause sync issues like the one here.  What you should do is invoke the calls that update the Appearance back to the main UI Thread in order to perform the update.

    -Matt

Reply Children