Announcement

Collapse
No announcement yet.

couple code questions, since i'm coding again :)

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • couple code questions, since i'm coding again :)

    Since John has been posting lately, it really did invogorate me to get back to looking at some of the code. Since then, I have actually drawn up a design that I think might work. I am working on a couple different plugins (including a complete re-write of my sports plugin since I lost the code) and have just thought of a couple questions while designing. My apologies if these are easy to see in the IDE but here goes:

    Is there a z-order set for your controls? The normal .net environment used a .sendtoback or .bringtofront. Or is it set on the order in which controls are added?

    I've thought of using a couple different pulldown menu's to house buttons. Keeps the screen clear. I set the "up" and "down" portions in two different functions, then call either one as a separate safethread.asynchronous, so I'll assume the functions are called on separate threads. If the user activates one without the other finishing it would cause problems. I remember reading a while back of being able to 'queue' things, is that feasible with functions? Or, can code be locked out easily without a rediculous boolean variable hack checking it almost everyline if you need to exit?

    Other than that, new designs are going well and fast, almost ready to jump back into the actual coding! Thanks for the renewed interest
    Current Worklog: TBA - '05 Rav4 (Mobo Dead).
    www.rav4world.com - Forums for Rav4 owners
    www.flavorfeasts.com - Cooking website/forums
    -Basic forums live atm, come contribute!

  • #2
    Hello detlion.

    Glad to have re-ignited the fire!

    One of the hardcore devs will have to answer these questions for you. I think I can partially answer your Z-order question. While you are coding .Net, you are not using forms based coding, so the senttoback and bringtofront don't apply. I'm pretty sure OM provides such functionality, but this is currently where my knowledge ends (can't tell you what many of the methods and properties are for many things).

    The guys have been away for a few days (work, vacation, whatever) and will probably reply soon.

    Cheers,
    John
    03 Cadillac CTS
    ZOTAC G43ITX-A-E 2.5ghz Core i3 2GB 160GB SSD
    Win7 Ultimate - OpenMobile - Directed HD - Wifi
    OMMaps + MS GPS Puck - WiFi via LTE Android phone
    2 Zones - Matrix Orbital LCD - Arduino - Build Pics

    Comment


    • #3
      Originally posted by detlion1643 View Post
      Since John has been posting lately, it really did invogorate me to get back to looking at some of the code. Since then, I have actually drawn up a design that I think might work. I am working on a couple different plugins (including a complete re-write of my sports plugin since I lost the code) and have just thought of a couple questions while designing.
      Nice to see you back in action again!

      Originally posted by detlion1643 View Post
      Is there a z-order set for your controls? The normal .net environment used a .sendtoback or .bringtofront. Or is it set on the order in which controls are added?
      It is set by the order it's added but you can also affect it by using the following methods of the OMPanel object; increaseZOrder, decreaseZOrder, MoveControlToBack and MoveControlToFront.

      Originally posted by detlion1643 View Post
      I've thought of using a couple different pulldown menu's to house buttons. Keeps the screen clear. I set the "up" and "down" portions in two different functions, then call either one as a separate safethread.asynchronous, so I'll assume the functions are called on separate threads. If the user activates one without the other finishing it would cause problems. I remember reading a while back of being able to 'queue' things, is that feasible with functions? Or, can code be locked out easily without a rediculous boolean variable hack checking it almost everyline if you need to exit?
      Easiest way of controlling access to an object is by "locking" it;
      Pseudo-code:
      Code:
      lock (object to lock or a dummy object)
      {
         ....... Up/down code .......
      }
      This code would block other threads from accessing an object until the current lock has been released, which happens when the other thread exits.
      Failure is not an option...
      __________________________________________________ ______________________________
      The only full multizone / multiscreen cross platform open source Front End -> OpenMobile

      Comment


      • #4
        ^^^ Thanks! Putting that stuff to good use.

        I have thought about something else that might help:

        I know there is a way to make multiple panels, and transition between them and whatnot, however, trying to look through the plugins, I cannot seem to figure it out ::.
        None of the original "main" panels in any plugin is given a name (ex, ompanel panelmain = new ompanel(). I have seen the next panel get a name though (ex, ompanel subpanel = new ompanel("subpanel"). Yet, it seems like every .transitiontopanel or .executetransition or anything to do with that always mentions a "Main Menu" and "subpanel", or a line with no mention of panel names? Is it possible to get quick psuedo-code to finish this out if possible:
        Code:
        OMPanel main = new OMPanel();
        OMPanel sub = new OMPanel("sub");
        ... other code here (including 2 buttons for this example) ...
        
        button1clickcode
        {
        //transition to "sub" panel here please
        }
        
        button2clickcode
        {
        //transition back to "main" panel here please - or original panel upon plugin load
        }
        I know the other code and code for buttons and all, the transitions need filled in. It would streamline my plugin so much, and allow me to sort and place the code and I'll know where things are! It would speed it up and make it more efficient as well since I'm going to have so much going on in it.
        Current Worklog: TBA - '05 Rav4 (Mobo Dead).
        www.rav4world.com - Forums for Rav4 owners
        www.flavorfeasts.com - Cooking website/forums
        -Basic forums live atm, come contribute!

        Comment


        • #5
          Originally posted by detlion1643 View Post
          Is it possible to get quick psuedo-code to finish this out if possible:
          Code:
          OMPanel main = new OMPanel("main");
          OMPanel sub = new OMPanel("sub");
          ... other code here (including 2 buttons for this example) ...
          
          button1clickcode
          {
          //transition to "sub" panel here please
          
          // Transit panel Main Out
                      Host.execute(eFunction.TransitionFromPanel, screen.ToString(), (Name of your plugin), (Name of panel to remove; in this case "main"));
          
          // Transit panel Sub IN
                      Host.execute(eFunction.TransitionToPanel, screen.ToString(), (Name of your plugin), (Name of panel to show; in this case "sub"));
          
          // Execute requested transition
                      Host.execute(eFunction.ExecuteTransition, screen.ToString(), "SlideLeft");
          
          // Please note that you don't have to remove a panel unless you don't need it anymore. If you just 
          // want to show something temporarily to the user then transition your new panel in, do something 
          // then go back.
          }
          
          button2clickcode
          {
          //transition back to "main" panel here please - or original panel upon plugin load
                              Host.execute(eFunction.goBack, screen.ToString());
          
          }
          Not sure if the above code was what you where looking for, if not I'll provide another example.

          Naming of panels has been somewhat confusing earlier (this has now been addressed in the current development code) as if there is no name provided it means "default panel". All other panels would require named access. But basic rule (to keep your code compatible with future requirement) is to always use a name for you panels.
          So in your case I'd give the name "Main" to your panel without a name.
          Failure is not an option...
          __________________________________________________ ______________________________
          The only full multizone / multiscreen cross platform open source Front End -> OpenMobile

          Comment


          • #6
            Naming of panels has been somewhat confusing earlier (this has now been addressed in the current development code) as if there is no name provided it means "default panel". All other panels would require named access. But basic rule (to keep your code compatible with future requirement) is to always use a name for you panels.
            So in your case I'd give the name "Main" to your panel without a name.
            Just did a quick test, but here's what happened:
            If I don't give a name to the "main" panel, it will load up as the first panel for the plugin. If I give a name of "main" to it, no panel loads when clicking the plugin. Without the "main" name for the panel, the .TransitionFromPanel function can be commented out, and the .TransitionToPanel function still works (the new "sub" panel shows) as noted in the code. But not removing the panels results in the first un-named panel to appear again when clicking out of the plugin (back home) and back into the plugin.

            The last version I bothered getting to dev with was back from April sometime... Maybe since you mentioned naming problems, I still have a version with naming problems?

            EDIT: Adding another in real fast before bed... If I add a systems.timers.timer with a tick event for every 30 seconds, the timer seems to start ok, but causes problems because my controls haven't really been set yet. Inside the timer tick event, I loop through the host.screencount and perform the update of data like this:
            Code:
            void updatetimer_tick(object sender, System.Timers.ElapsedEventArgs e)
                    {
                        for (int i = 0; i < theHost.ScreenCount; i++)
                        {
                            OMList sportslist = (OMList)manager[i]["sportslist"];
                            sportslist.Clear();
                            SafeThread.Asynchronous(delegate() { fillsportslist(i); }, theHost);
                        }
                    }
            but inside the fillsportslist(screen) function it errors on this line:
            Code:
            OMList sportslist = (OMList)manager[screen]["sportslist"];
            saying "Index was outside the bounds of the array." Hovering over sportslists gives a value of null. So, sportslist hasn't been set yet (everything works without the timer). Is there a way around getting the controls set or the timer calling the controls before they actually set. This happens because I have not clicked into my plugin yet, so as I come to think of no controls for my plugin are really set yet at all?
            Last edited by detlion1643; 08-25-2011, 09:47 PM.
            Current Worklog: TBA - '05 Rav4 (Mobo Dead).
            www.rav4world.com - Forums for Rav4 owners
            www.flavorfeasts.com - Cooking website/forums
            -Basic forums live atm, come contribute!

            Comment


            • #7
              Originally posted by detlion1643 View Post
              Just did a quick test, but here's what happened:
              If I don't give a name to the "main" panel, it will load up as the first panel for the plugin. If I give a name of "main" to it, no panel loads when clicking the plugin. Without the "main" name for the panel, the .TransitionFromPanel function can be commented out, and the .TransitionToPanel function still works (the new "sub" panel shows) as noted in the code. But not removing the panels results in the first un-named panel to appear again when clicking out of the plugin (back home) and back into the plugin.
              The last version I bothered getting to dev with was back from April sometime... Maybe since you mentioned naming problems, I still have a version with naming problems?
              This is not a naming problem, your plugin (as in you) are the one responsible for loading the panel you want to show when the frameworks asks for a panel without any name. This is all handled in the loadPanel method in your plugin. There you check for a panalname equal "", if true return the panel you want to show/hide/affect. This is the default panel for your plugin.

              Originally posted by detlion1643 View Post
              EDIT: Adding another in real fast before bed... If I add a systems.timers.timer with a tick event for every 30 seconds, the timer seems to start ok, but causes problems because my controls haven't really been set yet. Inside the timer tick event, I loop through the host.screencount and perform the update of data like this:
              Code:
              void updatetimer_tick(object sender, System.Timers.ElapsedEventArgs e)
                      {
                          for (int i = 0; i < theHost.ScreenCount; i++)
                          {
                              OMList sportslist = (OMList)manager[i]["sportslist"];
                              sportslist.Clear();
                              SafeThread.Asynchronous(delegate() { fillsportslist(i); }, theHost);
                          }
                      }
              but inside the fillsportslist(screen) function it errors on this line:
              Code:
              OMList sportslist = (OMList)manager[screen]["sportslist"];
              saying "Index was outside the bounds of the array." Hovering over sportslists gives a value of null. So, sportslist hasn't been set yet (everything works without the timer). Is there a way around getting the controls set or the timer calling the controls before they actually set. This happens because I have not clicked into my plugin yet, so as I come to think of no controls for my plugin are really set yet at all?
              You load all the controls you need in the initialization part of your plugin, if this is done then they are accessible from thereon. What panel are they located on? Since you didn't pass a panel name along with the screen number it tries to use a control from the panel with no name in it.
              Use the following code to access a given control on a given panel (this is the command that you should always use, access without passing a name along will be discarded in later versions):
              Code:
              OMList sportslist = (OMList)manager[screen, panelName]["sportslist"];
              Failure is not an option...
              __________________________________________________ ______________________________
              The only full multizone / multiscreen cross platform open source Front End -> OpenMobile

              Comment


              • #8
                Actually, for the timer part, I haven't named a single panel yet (in fact, I only have the 1 still). So, I have 1 panel, not named, but loads correctly if I click into the plugin. However, even after clicking into the plugin and filling the sportslist, the timer still causes problems. I'm just commenting out the timer.enabled part because it's not the end all be all of the plugin.

                I'm probably starting to sound like a pain for all these questions, but I'm still a little confused as how to control which panel is actually loaded first? You need to load all panels through the intialize function, correct?

                Code:
                public OMPanel loadPanel(string name, int screen)
                        {
                            if (manager == null)
                                return null;
                            return manager[screen, name];
                        }
                [code]this.manager.loadPanel(p); //has no name
                this.manager.loadPanel(s); //has name of sub
                return eLoadStatus.LoadSuccessful;[code]
                This is what I'm referring to, if I give panel p a name of "main", it doesn't load... I'll bug off a little and keep coding my sports plugin, sorry for all these questions again...
                Current Worklog: TBA - '05 Rav4 (Mobo Dead).
                www.rav4world.com - Forums for Rav4 owners
                www.flavorfeasts.com - Cooking website/forums
                -Basic forums live atm, come contribute!

                Comment


                • #9
                  Originally posted by detlion1643 View Post
                  Actually, for the timer part, I haven't named a single panel yet (in fact, I only have the 1 still). So, I have 1 panel, not named, but loads correctly if I click into the plugin. However, even after clicking into the plugin and filling the sportslist, the timer still causes problems. I'm just commenting out the timer.enabled part because it's not the end all be all of the plugin.
                  Not quite sure I follow you on this problem. Could you post some of your code?

                  Originally posted by detlion1643 View Post
                  I'm probably starting to sound like a pain for all these questions, but I'm still a little confused as how to control which panel is actually loaded first? You need to load all panels through the intialize function, correct?
                  No worries. I'm glad you're interested and quite happy to help out.

                  Your initialize method should look like this:
                  Code:
                  public eLoadStatus initialize(IPluginHost host)
                  {
                  OMPanel p = new OMPanel("main");
                  OMPanel s = new OMPanel("sub");
                  
                  ... Add controls ...
                  
                  this.manager.loadPanel(p);
                  this.manager.loadPanel(s);
                  return eLoadStatus.LoadSuccessful;
                  }
                  Your loadPanel method should look like this:
                  Code:
                  public OMPanel loadPanel(string name, int screen)
                          {
                              // Errorhandling
                              if (manager == null)
                                  return null;
                  
                              // Load default panel
                              if (name == "")
                                  return manager[screen, "main"];
                  
                              // Return requested panel
                              return manager[screen, name];
                          }
                  The reason why a panel named "main" doesn't load is because the framework doesn't know which panel to load by default (hence no name passed along) so you have to catch this request and return the panel you want to load as default.
                  Failure is not an option...
                  __________________________________________________ ______________________________
                  The only full multizone / multiscreen cross platform open source Front End -> OpenMobile

                  Comment


                  • #10
                    Your initialize method should look like this:
                    Code:
                    public eLoadStatus initialize(IPluginHost host)
                    {
                    OMPanel p = new OMPanel("main");
                    OMPanel s = new OMPanel("sub");

                    ... Add controls ...

                    this.manager.loadPanel(p);
                    this.manager.loadPanel(s);
                    return eLoadStatus.LoadSuccessful;
                    }
                    Your loadPanel method should look like this:
                    Code:
                    public OMPanel loadPanel(string name, int screen)
                    {
                    // Errorhandling
                    if (manager == null)
                    return null;

                    // Load default panel
                    if (name == "")
                    return manager[screen, "main"];

                    // Return requested panel
                    return manager[screen, name];
                    }
                    The reason why a panel named "main" doesn't load is because the framework doesn't know which panel to load by default (hence no name passed along) so you have to catch this request and return the panel you want to load as default.
                    Works good, and the transitions a couple posts back are working good as well. If I transitionfrompanel "main" topanel "sub", click home, and back into my plugin I am at the "main" panel again. I figured this would be the case, so is there a way to leave the plugin somehow remember what panel you were on, and somehow navigate back to that panel?

                    Not quite sure I follow you on this problem. Could you post some of your code?
                    Sure (this is the most simplified version I have working - none of the new panel names and additional panels are included yet in this attempt):
                    Code:
                    namespace OMSports
                    {
                        public class OMSports : IHighLevel
                        {
                            private ScreenManager manager;
                            private IPluginHost theHost;
                            private Settings settings;
                            private System.Timers.Timer updatetimer = new System.Timers.Timer();
                    
                            public OMPanel loadPanel(string name, int screen)
                            {
                                if (manager == null)
                                    return null;
                                return manager[screen, name];
                            }
                    
                            public eLoadStatus initialize(IPluginHost host)
                            {
                                OMPanel p = new OMPanel();
                    
                                OMList sportslist = new OMList(0, 175, 600, 275);
                                sportslist.Name = "sportslist";
                                sportslist.ListStyle = eListStyle.MultiListText;
                                //sportslist.OnClick += new userInteraction(sportslist_onclick);
                                sportslist.Visible = false;
                    
                                updatetimer.Interval = 30000; //30 second update
                                updatetimer.Elapsed += new System.Timers.ElapsedEventHandler(updatetimer_tick);
                                updatetimer.Enabled = true;
                    
                                this.manager.loadPanel(p);
                                return eLoadStatus.LoadSuccessful;
                            }
                    
                             void updatetimer_tick(object sender, System.Timers.ElapsedEventArgs e)
                            {
                                for (int i = 0; i < theHost.ScreenCount; i++)
                                {
                                    OMList sportslist = (OMList)manager[i]["sportslist"];
                                    sportslist.Clear();
                                    SafeThread.Asynchronous(delegate() { fillsportslist(i); }, theHost);
                                }
                            }
                    
                            private void fillsportslist(int screen)
                            {
                                OMList sportslist = (OMList)manager[screen]["sportslist"];
                                ........snip.............
                            }
                    
                        } //end class
                    } //end namespace
                    Current Worklog: TBA - '05 Rav4 (Mobo Dead).
                    www.rav4world.com - Forums for Rav4 owners
                    www.flavorfeasts.com - Cooking website/forums
                    -Basic forums live atm, come contribute!

                    Comment


                    • #11
                      Originally posted by detlion1643 View Post
                      So is there a way to leave the plugin somehow remember what panel you were on, and somehow navigate back to that panel?
                      There is no function in the framework to handle this. If you want to go back to different panels (like the last used) you have to maintain a log of this internally in your plugin and then load the different panels via the loadPanel method.

                      Originally posted by detlion1643 View Post
                      Sure (this is the most simplified version I have working - none of the new panel names and additional panels are included yet in this attempt):
                      I still don't see an error but add the rest of the code in and post some code including the one updating the list then I can try to test it here on my side to find the error.
                      Last edited by Borte; 08-26-2011, 04:24 PM. Reason: Additional info
                      Failure is not an option...
                      __________________________________________________ ______________________________
                      The only full multizone / multiscreen cross platform open source Front End -> OpenMobile

                      Comment


                      • #12
                        I"m just going to post the entire thing, as you never know if we keep taking bits at a time from it. Remember, my last dev version I'm compiling against was April. If you need anything else I'll be all night. A Friday night of coding, woot! /sarcasm...

                        EDIT: Forgot to un-comment the updatetimer.enabled=true; line...

                        Code:
                        /*********************************************************************************
                            This file is part of Open Mobile.
                        
                            Open Mobile is free software: you can redistribute it and/or modify
                            it under the terms of the GNU General Public License as published by
                            the Free Software Foundation, either version 3 of the License, or
                            (at your option) any later version.
                        
                            Open Mobile is distributed in the hope that it will be useful,
                            but WITHOUT ANY WARRANTY; without even the implied warranty of
                            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                            GNU General Public License for more details.
                        
                            You should have received a copy of the GNU General Public License
                            along with Open Mobile.  If not, see <http://www.gnu.org/licenses/>.
                         
                            There is one additional restriction when using this framework regardless of modifications to it.
                            The About Panel or its contents must be easily accessible by the end users.
                            This is to ensure all project contributors are given due credit not only in the source code.
                        *********************************************************************************/
                        using OpenMobile;
                        using OpenMobile.Controls;
                        using OpenMobile.Data;
                        using OpenMobile.Framework;
                        using OpenMobile.Graphics;
                        using OpenMobile.Media;
                        using OpenMobile.Plugin;
                        using OpenMobile.Threading;
                        using System;
                        using System.Net;
                        using System.IO;
                        using System.Threading;
                        
                        namespace OMSports
                        {
                            public class OMSports : IHighLevel
                            {
                                private ScreenManager manager;
                                private IPluginHost theHost;
                                private Settings settings;
                                private System.Timers.Timer updatetimer = new System.Timers.Timer();
                        
                                /// <summary>
                                /// loadPanel is called everytime a panel is loaded or unloaded.
                                /// It should return the panel containing your controls.
                                /// </summary>
                                /// <param name="name">The name of the panel (or an empty string for the default panel)</param>
                                /// <param name="screen">The screen number requesting a panel</param>
                                /// <returns></returns>
                                public OMPanel loadPanel(string name, int screen)
                                {
                                    if (manager == null)
                                        return null;
                                    return manager[screen, name];
                                }
                        
                                public Settings loadSettings()
                                {
                                    //If a plugin does not expose settings null may be returned
                                    /*
                                            if (settings == null)
                                            {
                                                settings = new Settings("PluginSample settings");
                                                using (PluginSettings setting = new PluginSettings())
                                                {
                                                    settings.Add(new Setting(SettingTypes.MultiChoice, "OMPluginSample.Setting1", "", "Setting description goes here", Setting.BooleanList, Setting.BooleanList, setting.getSetting("OMPluginSample.Setting1")));
                                                }
                                                settings.OnSettingChanged += new SettingChanged(Setting_Changed);
                                            }
                                            //Settings collections are automatically laid out by the framework
                                            return settings;
                                    */
                                    return null;
                                }
                        
                                /*
                                    private void Setting_Changed(int scr,Setting s)
                                    {
                                        //When a setting changes you should update your plugin with
                                        //the new setting information
                        
                                        //Then the setting should be saved to the database
                                        using (PluginSettings settings = new PluginSettings())
                                            settings.setSetting(s.Name, s.Value);
                                    }
                                */
                        
                                /// <summary>
                                /// The name that will be displayed on a main menu button
                                /// </summary>
                                public string displayName
                                {
                                    get { return "OMSports"; }
                                }
                        
                                //#region IBasePlugin Members
                        
                                public string authorName
                                {
                                    get { return "Peter Yeaney"; }
                                }
                                public string authorEmail
                                {
                                    get { return "[email protected]"; }
                                }
                                public string pluginName
                                {
                                    get { return "OMSports"; }
                                }
                                public float pluginVersion
                                {
                                    get { return 0.1F; }
                                }
                                public string pluginDescription
                                {
                                    get { return "OMSports plugin"; }
                                }
                        
                                public bool incomingMessage(string message, string source)
                                {
                                    return false;
                                }
                                public bool incomingMessage<T>(string message, string source, ref T data)
                                {
                                    return false;
                                }
                        
                                public void Dispose()
                                {
                                    //
                                }
                        
                                public eLoadStatus initialize(IPluginHost host)
                                {
                                    OMPanel p = new OMPanel();
                                    if (host.InstanceCount == -1)
                                        return eLoadStatus.LoadFailedRetryRequested;
                                    this.manager = new ScreenManager(host.ScreenCount);
                                    this.theHost = host;
                        
                                    //all controls to be initialized upon plugin load here
                        
                                    //has dropdown - sportsselectionlist
                                    OMButton topbutton1 = new OMButton(0, 100, 200, 75);
                                    topbutton1.Name = "topbutton1";
                                    topbutton1.Text = "Sport";
                                    topbutton1.Tag = "up";
                                    topbutton1.Image = theHost.getSkinImage("FULL");
                                    topbutton1.OnClick += new userInteraction(topbutton1_onclick);
                        
                                    //has dropdown - sportssubselectionlist
                                    OMButton topbutton2 = new OMButton(200, 100, 200, 75);
                                    topbutton2.Name = "topbutton2";
                                    topbutton2.Text = "";
                                    topbutton2.Tag = "up";
                                    topbutton2.Image = theHost.getSkinImage("FULL");
                                    topbutton2.OnClick += new userInteraction(topbutton2_onclick);
                        
                                    //has dropdown - sportssubsubselectionlist
                                    OMButton topbutton3 = new OMButton(400, 100, 200, 75);
                                    topbutton3.Name = "topbutton3";
                                    topbutton3.Text = "";
                                    topbutton3.Tag = "up";
                                    topbutton3.Image = theHost.getSkinImage("FULL");
                                    //topbutton3.onClick += new userInteraction(topbutton3_onclick);
                        
                                    OMButton topbutton4 = new OMButton(600, 100, 200, 75);
                                    topbutton4.Name = "topbutton4";
                                    topbutton4.Text = "";
                                    topbutton4.Image = theHost.getSkinImage("FULL");
                                    //topbutton4.onClick += new userInteraction(topbutton4_onclick);
                        
                        
                                    OMButton universalsettings = new OMButton(800, 100, 200, 75);
                                    universalsettings.Name = "universalsettings";
                                    universalsettings.Text = "Settings";
                                    universalsettings.Image = theHost.getSkinImage("FULL");
                                    //universalsettings.onClick += new userInteraction(universalsettings_onclick);
                        
                                    //sportsselectionlist dropdown
                                    OMList sportsselectionlist = new OMList(20, 115, 160, 60);
                                    sportsselectionlist.ListStyle = eListStyle.MultiListText;
                                    sportsselectionlist.Name = "sportsselectionlist";
                                    sportsselectionlist.Tag = "sportsselectionlist";
                                    sportsselectionlist.ListItemHeight = 60;
                                    sportsselectionlist.TextAlignment = Alignment.CenterCenter;
                                    sportsselectionlist.Add("NFL");
                                    sportsselectionlist.Add("NBA");
                                    sportsselectionlist.Add("MLB");
                                    sportsselectionlist.Add("NHL");
                                    sportsselectionlist.Height = sportsselectionlist.Count * 60;
                                    if (sportsselectionlist.Count > 1)
                                    {
                                        int newcount = sportsselectionlist.Count - 1;
                                        sportsselectionlist.Top = sportsselectionlist.Top - (newcount * 60);
                        
                                    }
                                    sportsselectionlist.OnClick += new userInteraction(sportsselectionlist_onclick);
                        
                                    OMList sportssubselectionlist = new OMList(220, 115, 160, 60);
                                    sportsselectionlist.ListStyle = eListStyle.MultiListText;
                                    sportssubselectionlist.Name = "sportssubselectionlist";
                                    sportssubselectionlist.Tag = "sportssubselectionlist";
                                    sportssubselectionlist.ListItemHeight = 60;
                                    sportssubselectionlist.TextAlignment = Alignment.CenterCenter;
                                    sportssubselectionlist.Add("Game Info");
                                    sportssubselectionlist.Add("Team Info");
                                    sportssubselectionlist.Height = sportssubselectionlist.Count * 60;
                                    if (sportssubselectionlist.Count > 1)
                                    {
                                        int newcount = sportssubselectionlist.Count - 1;
                                        sportssubselectionlist.Top = sportssubselectionlist.Top - (newcount * 60);
                        
                                    }
                                    sportssubselectionlist.OnClick += new userInteraction(sportssubselectionlist_onclick);
                        
                                    OMList sportslist = new OMList(0, 175, 600, 275);
                                    sportslist.Name = "sportslist";
                                    sportslist.ListStyle = eListStyle.MultiListText;
                                    //sportslist.OnClick += new userInteraction(sportslist_onclick);
                                    sportslist.Visible = false;
                        
                                    OMLabel currentscreen = new OMLabel(0, 0, 0, 0);
                                    currentscreen.Name = "currentscreen";
                                    currentscreen.Tag = "";
                                    currentscreen.Visible = false;
                        
                                    OMLabel currentsubscreen = new OMLabel(0, 0, 0, 0);
                                    currentsubscreen.Name = "currentsubscreen";
                                    currentsubscreen.Tag = "";
                                    currentsubscreen.Visible = false;
                        
                                    p.addControl(sportslist);
                                    p.addControl(sportsselectionlist); //sportsselectionlist dropdown portion
                                    p.addControl(sportssubselectionlist);
                                    p.addControl(topbutton1); 
                                    p.addControl(topbutton2);
                                    p.addControl(topbutton3);
                                    p.addControl(topbutton4);
                                    p.addControl(universalsettings);
                                    p.addControl(currentscreen);
                                    p.addControl(currentsubscreen);
                        
                                    //timer to auto-update sportslist if games view or seperate game view is displayed...
                                    updatetimer.Interval = 30000; //30 second update
                                    updatetimer.Elapsed += new System.Timers.ElapsedEventHandler(updatetimer_tick);
                                    updatetimer.Enabled = true;
                        
                                    this.manager.loadPanel(p);
                                    return eLoadStatus.LoadSuccessful;
                                }
                        
                                void updatetimer_tick(object sender, System.Timers.ElapsedEventArgs e)
                                {
                                    for (int i = 0; i < theHost.ScreenCount; i++)
                                    {
                                        OMList sportslist = (OMList)manager[i]["sportslist"];
                                        sportslist.Clear();
                                        SafeThread.Asynchronous(delegate() { fillsportslist(i); }, theHost);
                                    }
                                }
                        
                                /*
                                private void clearcenter(int screen)
                                {
                                    //clear center controls except for leftbuttons and topbuttons
                                    do
                                        {
                                            for (int index = 0; index <= this.manager[screen].controlCount - 1; ++index)
                                            {
                                                OMControl control1 = this.manager[screen].getControl(index);
                                                if (!(control1.Name == "leftbutton1") && !(control1.Name == "leftbutton2") && !(control1.Name == "leftbutton3") && !(control1.Name == "topbutton1") && !(control1.Name == "topbutton2") && !(control1.Name == "topbutton3") && !(control1.Name == "universalsettings") && !(control1.Name == "picturebox1"))
                                                    omPanel.Remove(control1);
                                            }
                                        }
                                        while (this.manager[screen].controlCount > 8);
                        
                                    //set shoutcast opening screen
                        
                                }
                                */
                        
                                private void hidecenter(int screen)
                                {
                                    //clear center controls except for leftbuttons and topbuttons
                                    //do
                                    //{
                                    for (int index = 0; index <= this.manager[screen].controlCount - 1; ++index)
                                    {
                                        OMControl control1 = this.manager[screen].getControl(index);
                                        if (!(control1.Name == "topbutton1") && !(control1.Name == "topbutton2") && !(control1.Name == "topbutton3") && !(control1.Name == "topbutton4") && !(control1.Name == "universalsettings") && !(control1.Name == "musiclist"))
                                            control1.Visible = false;
                                    }
                                    //}
                                    //while (this.manager[screen].controlCount > 7);
                        
                                }
                        
                                private void fillsportslist(int screen)
                                {
                                    OMList sportslist = (OMList)manager[screen]["sportslist"];
                                    OMLabel currentscreen = (OMLabel)manager[screen]["currentscreen"];
                                    OMLabel currentsubscreen = (OMLabel)manager[screen]["currentsubscreen"];
                                    string sport = Convert.ToString(currentscreen.Tag);
                                    string sportinfo = Convert.ToString(currentsubscreen.Tag);
                                    if ((sport == "NFL") && (sportinfo == "Game Info"))
                                    {
                                        //set up sportslist and multi-lines
                                        sportslist.Font = new Font(Font.GenericSansSerif, 22F);
                                        sportslist.TextAlignment = Alignment.TopCenter;
                                        sportslist.ListItemHeight = 80;
                                        OMListItem.subItemFormat sf = new OMListItem.subItemFormat();
                                        sf.font = new Font(Font.GenericSansSerif, 18F);
                                        sf.textAlignment = Alignment.BottomLeft;
                                        sportslist.Visible = true;
                                        //sportslist.Add("Loading current game information...");
                                        WebRequest req = WebRequest.Create("http://www.nfl.com/scores");
                                        WebResponse resp = req.GetResponse();
                                        using (StreamReader streamreader = new StreamReader(resp.GetResponseStream()))
                                        {
                                            string gameinfohtml = streamreader.ReadToEnd();
                                            //get title of current week
                                            string title = gameinfohtml.Remove(0, gameinfohtml.IndexOf("<title>")+7);
                                            title = title.Substring(0, title.IndexOf("</title>") - 2);
                                            string gameyear = title.Remove(0, title.IndexOf(":") + 2);
                                            gameyear = gameyear.Substring(0, gameyear.IndexOf(" "));
                                            //loop through and get ALL game data into one array
                                            //seperate out into active games first, scheduled games next, finished games last
                                            do
                                            {
                                                //found game
                                                gameinfohtml = gameinfohtml.Remove(0, gameinfohtml.IndexOf("<!-- BEGIN INCLUDE scoresbox/")+29);
                                                //scoresbox/post - game over... scoresbox/pre - game scheduled (not started yet)... scoresbox/active - game active
                                                string gamestatus = gameinfohtml.Substring(0, gameinfohtml.IndexOf(" "));
                                                string gamedate = gameinfohtml.Remove(0, gameinfohtml.IndexOf("the-date") + 10);
                                                gamedate = gamedate.Substring(0, gamedate.IndexOf("<"));
                                                string gameday = gamedate.Remove(0, gamedate.LastIndexOf(" ")+1);
                                                string gamemonth = gamedate.Remove(0, gamedate.IndexOf(",")+2);
                                                gamemonth = gamemonth.Substring(0, gamemonth.IndexOf(" "));
                                                //have month (string), day, year... need to convert month to numerical value still
                                                gamedate = gamemonth + " " + gameday + " " + gameyear;
                                                //in order to compare dates for listing scheduled games in order
                                                string awayteamcity = gameinfohtml.Remove(0, gameinfohtml.IndexOf("away-team"));
                                                string awayteamnickname = awayteamcity.Remove(0, awayteamcity.IndexOf("nickname") + 10);
                                                awayteamnickname = awayteamnickname.Substring(0, awayteamnickname.IndexOf("<"));
                                                awayteamcity = awayteamcity.Remove(0, awayteamcity.IndexOf("city-name") + 11);
                                                awayteamcity = awayteamcity.Substring(0, awayteamcity.IndexOf("<"));
                                                string awayteamname = awayteamcity + " " + awayteamnickname;
                                                string hometeamcity = gameinfohtml.Remove(0, gameinfohtml.IndexOf("home-team"));
                                                string hometeamnickname = hometeamcity.Remove(0, hometeamcity.IndexOf("nickname") + 10);
                                                hometeamnickname = hometeamnickname.Substring(0, hometeamnickname.IndexOf("<"));
                                                hometeamcity = hometeamcity.Remove(0, hometeamcity.IndexOf("city-name") + 11);
                                                hometeamcity = hometeamcity.Substring(0, hometeamcity.IndexOf("<"));
                                                string hometeamname = hometeamcity + " " + hometeamnickname;
                                                string awayteamscore = "";
                                                string hometeamscore = "";
                                                string gametime = "";
                                                if (gamestatus == "pre")
                                                {
                                                    awayteamscore = gameinfohtml.Remove(0, gameinfohtml.IndexOf("away-score"));
                                                    awayteamscore = awayteamscore.Remove(0, awayteamscore.IndexOf("the-score") + 11);
                                                    awayteamscore = awayteamscore.Substring(0, awayteamscore.IndexOf("<"));
                                                    hometeamscore = gameinfohtml.Remove(0, gameinfohtml.IndexOf("home-score"));
                                                    hometeamscore = hometeamscore.Remove(0, hometeamscore.IndexOf("the-score") + 11);
                                                    hometeamscore = hometeamscore.Substring(0, hometeamscore.IndexOf("<"));
                                                    gametime = gameinfohtml.Remove(0, gameinfohtml.IndexOf("pre-time") + 10);
                                                    gametime = gametime.Substring(0, gametime.IndexOf(" "));
                                                    gamedate = gamedate + " - " + gametime;
                                                }
                                                else if (gamestatus == "active")
                                                {
                                                    //get score from scores.espn.go.com/nfl/scoreboard
                                                    WebRequest reqespn = WebRequest.Create("http://www.espn.go.com/nfl/scoreboard");
                                                    WebResponse respespn = reqespn.GetResponse();
                                                    
                                                    //Thread.Sleep(500);
                                                    using (StreamReader streamreaderespn = new StreamReader(respespn.GetResponseStream()))
                                                    {
                                                        string scoreinfohtml = streamreaderespn.ReadToEnd();
                                                        scoreinfohtml = scoreinfohtml.Remove(0, scoreinfohtml.IndexOf("gameDay-Container"));
                                                        gametime = scoreinfohtml.Substring(0, scoreinfohtml.IndexOf(awayteamnickname));
                                                        scoreinfohtml = scoreinfohtml.Remove(0, scoreinfohtml.IndexOf(awayteamnickname));
                                                        string awayscore1 = scoreinfohtml.Remove(0, scoreinfohtml.IndexOf("aScore1") + 9);
                                                        awayscore1 = awayscore1.Substring(0, awayscore1.IndexOf("<"));
                                                        string awayscore2 = scoreinfohtml.Remove(0, scoreinfohtml.IndexOf("aScore2") + 9);
                                                        awayscore2 = awayscore2.Substring(0, awayscore2.IndexOf("<"));
                                                        string awayscore3 = scoreinfohtml.Remove(0, scoreinfohtml.IndexOf("aScore3") + 9);
                                                        awayscore3 = awayscore3.Substring(0, awayscore3.IndexOf("<"));
                                                        string awayscore4 = scoreinfohtml.Remove(0, scoreinfohtml.IndexOf("aScore4") + 9);
                                                        awayscore4 = awayscore4.Substring(0, awayscore4.IndexOf("<"));
                                                        if (awayscore1 == "&nbsp;") awayscore1 = "0";
                                                        if (awayscore2 == "&nbsp;") awayscore2 = "0";
                                                        if (awayscore3 == "&nbsp;") awayscore3 = "0";
                                                        if (awayscore4 == "&nbsp;") awayscore4 = "0";
                                                        awayteamscore = Convert.ToString(Convert.ToInt16(awayscore1) + Convert.ToInt16(awayscore2) + Convert.ToInt16(awayscore3) + Convert.ToInt16(awayscore4));
                                                        scoreinfohtml = scoreinfohtml.Remove(0, scoreinfohtml.IndexOf(hometeamnickname));
                                                        string homescore1 = scoreinfohtml.Remove(0, scoreinfohtml.IndexOf("hScore1") + 9);
                                                        homescore1 = homescore1.Substring(0, homescore1.IndexOf("<"));
                                                        string homescore2 = scoreinfohtml.Remove(0, scoreinfohtml.IndexOf("hScore2") + 9);
                                                        homescore2 = homescore2.Substring(0, homescore2.IndexOf("<"));
                                                        string homescore3 = scoreinfohtml.Remove(0, scoreinfohtml.IndexOf("hScore3") + 9);
                                                        homescore3 = homescore3.Substring(0, homescore3.IndexOf("<"));
                                                        string homescore4 = scoreinfohtml.Remove(0, scoreinfohtml.IndexOf("hScore4") + 9);
                                                        homescore4 = homescore4.Substring(0, homescore4.IndexOf("<"));
                                                        if (homescore1 == "&nbsp;") homescore1 = "0";
                                                        if (homescore2 == "&nbsp;") homescore2 = "0";
                                                        if (homescore3 == "&nbsp;") homescore3 = "0";
                                                        if (homescore4 == "&nbsp;") homescore4 = "0";
                                                        hometeamscore = Convert.ToString(Convert.ToInt16(homescore1) + Convert.ToInt16(homescore2) + Convert.ToInt16(homescore3) + Convert.ToInt16(homescore4));
                                                        //statustext for game time and qtr
                                                        gametime = gametime.Remove(0, gametime.LastIndexOf("statusText") + 12);
                                                        gametime = gametime.Substring(0, gametime.IndexOf("<"));
                                                        if (gametime.Contains("Halftime")) gametime = gametime.Remove(0, gametime.IndexOf(" ") + 1);
                                                        gamedate = gametime;
                                                    }
                                                }//end active
                                                sportslist.Add(new OMListItem(gamedate, awayteamscore + "  " + awayteamname + "\n" + hometeamscore + "  " + hometeamname, sf));
                                                gameinfohtml = gameinfohtml.Remove(0, gameinfohtml.IndexOf("<!-- END INCLUDE scores/"));
                                            }
                                            while (gameinfohtml.IndexOf("<!-- BEGIN INCLUDE scoresbox/") > 0);
                                        } //end of game info html
                                    } //end of sport=nfl and sportinfo = game info
                                }
                        
                                private void topbutton1_onclick(OMControl sender, int screen)
                                {
                                    //sportsselectionlist- start dropdown
                                    //SafeThread.Asynchronous(delegate() {hidecenter(screen);},theHost);
                        
                                    OMButton topbutton1 = (OMButton)manager[screen]["topbutton1"];
                                    OMList sportsselectionlist = (OMList)manager[screen]["sportsselectionlist"];
                                    if (Convert.ToString(topbutton1.Tag) == "up")
                                    {
                                        SafeThread.Asynchronous(delegate() { sportsoptionsdown(screen); }, theHost);
                                    }
                                    else if (Convert.ToString(topbutton1.Tag) == "down")
                                    {
                                        SafeThread.Asynchronous(delegate() { sportsoptionsup(screen); }, theHost);
                                    }
                                }
                        
                                
                                private void topbutton2_onclick(OMControl sender, int screen)
                                {
                                    OMButton topbutton2 = (OMButton)manager[screen]["topbutton2"];
                                    OMList sportssubselectionlist = (OMList)manager[screen]["sportssubselectionlist"];
                                    if (Convert.ToString(topbutton2.Tag) == "up")
                                    {
                                        SafeThread.Asynchronous(delegate() { sportssuboptionsdown(screen); }, theHost);
                                    }
                                    else if (Convert.ToString(topbutton2.Tag) == "down")
                                    {
                                        SafeThread.Asynchronous(delegate() { sportssuboptionsup(screen); }, theHost);
                                    }
                                }
                                
                        
                                /*
                                private void topbutton3_onclick(int screen)
                                {
                                    //shoutcast button
                                    SafeThread.Asynchronous(delegate() {hidecenter(screen);},theHost);
                        	
                                    //change 3 side buttons to perform shoutcast actions
                                    OMButton leftbutton1 = (OMButton)manager[screen]["leftbutton1"];
                                    leftbutton1.Text="Shoutcast";
                                    leftbutton1.Tag="shoutcast";
                                    leftbutton1.Visible = true;
                                    OMButton leftbutton2 = (OMButton)manager[screen]["leftbutton2"];
                                    leftbutton2.Text="Playlist";
                                    leftbutton2.Tag="shoutcast";
                                    leftbutton2.Visible = true;
                                    OMButton leftbutton3 = (OMButton)manager[screen]["leftbutton3"];
                                    leftbutton3.Text="Clear";
                                    leftbutton3.Tag="shoutcast";
                                    leftbutton3.Visible = true;
                                }
                                */
                        
                                private void universalsettings_onclick(OMControl sender, int screen)
                                {
                        
                                }
                        
                                private void sportsoptionsdown(int screen)
                                //
                                {
                                    lock (manager[screen]["topbutton1"])
                                    {
                                        OMButton topbutton1 = (OMButton)manager[screen]["topbutton1"];
                                        topbutton1.Tag = "down";
                                        OMList sportsselectionlist = (OMList)manager[screen]["sportsselectionlist"];
                                        int sportsselectionlistcount = sportsselectionlist.Count;
                                        int sportsselectionlistcountheight = sportsselectionlistcount * 60;
                                        for (int i = 0; i < sportsselectionlistcountheight / 5; i++)
                                        {
                                            sportsselectionlist.Top += 5;
                                            Thread.Sleep(10);
                                        }
                                    }
                                }
                        
                                private void sportsoptionsup(int screen)
                                {
                                    lock (manager[screen]["topbutton1"])
                                    {
                                        OMButton topbutton1 = (OMButton)manager[screen]["topbutton1"];
                                        topbutton1.Tag = "up";
                                        OMList sportsselectionlist = (OMList)manager[screen]["sportsselectionlist"];
                                        int sportsselectionlistcount = sportsselectionlist.Count;
                                        int sportsselectionlistcountheight = sportsselectionlistcount * 60;
                                        for (int i = 0; i < sportsselectionlistcountheight / 5; i++)
                                        {
                                            sportsselectionlist.Top += -5;
                                            Thread.Sleep(10);
                                        }
                                    }
                                }
                        
                                private void sportssuboptionsdown(int screen)
                                {
                                    OMButton topbutton2 = (OMButton)manager[screen]["topbutton2"];
                                    topbutton2.Tag = "down";
                                    OMList sportssubselectionlist = (OMList)manager[screen]["sportssubselectionlist"];
                                    int sportssubselectionlistcount = sportssubselectionlist.Count;
                                    int sportssubselectionlistcountheight = sportssubselectionlistcount * 60;
                                    for (int i = 0; i < sportssubselectionlistcountheight / 5; i++)
                                    {
                                        sportssubselectionlist.Top += 5;
                                        Thread.Sleep(10);
                                    }
                                }
                        
                                private void sportssuboptionsup(int screen)
                                {
                                    OMButton topbutton2 = (OMButton)manager[screen]["topbutton2"];
                                    topbutton2.Tag = "up";
                                    OMList sportssubselectionlist = (OMList)manager[screen]["sportssubselectionlist"];
                                    int sportssubselectionlistcount = sportssubselectionlist.Count;
                                    int sportssubselectionlistcountheight = sportssubselectionlistcount * 60;
                                    for (int i = 0; i < sportssubselectionlistcountheight / 5; i++)
                                    {
                                        sportssubselectionlist.Top += -5;
                                        Thread.Sleep(10);
                                    }
                                }
                        
                                private void sportsselectionlist_onclick(OMControl sender, int screen)
                                {
                                    OMList sportsselectionlist = (OMList)manager[screen]["sportsselectionlist"];
                                    OMLabel currentscreen = (OMLabel)manager[screen]["currentscreen"];
                                    //if not already on "nfl" page
                                    if (!(Convert.ToString(currentscreen.Tag) == sportsselectionlist.SelectedItem.text))
                                    {
                                        //hide center controls, then display correct sports screen
                                        currentscreen.Tag = sportsselectionlist.SelectedItem.text;
                                        OMButton topbutton2 = (OMButton)manager[screen]["topbutton2"];
                                        topbutton2.Text = sportsselectionlist.SelectedItem.text;
                                        SafeThread.Asynchronous(delegate() { sportssuboptionsdown(screen); }, theHost);
                                    }
                                    SafeThread.Asynchronous(delegate() { sportsoptionsup(screen); }, theHost);
                                }
                        
                                private void sportssubselectionlist_onclick(OMControl sender, int screen)
                                {
                                    OMList sportssubselectionlist = (OMList)manager[screen]["sportssubselectionlist"];
                                    OMLabel currentsubscreen = (OMLabel)manager[screen]["currentsubscreen"];
                                    if(!(Convert.ToString(currentsubscreen.Tag) == sportssubselectionlist.SelectedItem.text))
                                    {
                                        currentsubscreen.Tag = sportssubselectionlist.SelectedItem.text;
                                        //hide center controls, then display correct game or team info per sport
                                        OMButton topbutton2 = (OMButton)manager[screen]["topbutton2"];
                                        string sport = topbutton2.Text;
                                        if (sport == "NFL")
                                        {
                                            //display nfl info - let threaded function decide whether to display game or team info???
                                            SafeThread.Asynchronous(delegate() { fillsportslist(screen); }, theHost);
                                        }
                                    }
                                    SafeThread.Asynchronous(delegate() { sportssuboptionsup(screen); }, theHost);
                                }
                        
                        
                        
                        
                            } //end class level :ihighlevel
                        } //end namespace
                        Last edited by detlion1643; 08-26-2011, 04:39 PM.
                        Current Worklog: TBA - '05 Rav4 (Mobo Dead).
                        www.rav4world.com - Forums for Rav4 owners
                        www.flavorfeasts.com - Cooking website/forums
                        -Basic forums live atm, come contribute!

                        Comment


                        • #13
                          Originally posted by detlion1643 View Post
                          I"m just going to post the entire thing, as you never know if we keep taking bits at a time from it.
                          I looked at your code and the problem is caused by threading.
                          In your timer you have a for loop that passes the screen number (i) onto a new thread which calls fillsportslist. The problem is that when you create a new thread the screennumber (i) is changed in the meantime by the original timer thread that's running the for loop. In other words the screen number you're sending is not the same as the one you're receiving. This is one of the timing issues to keep in mind when working with multiple threads.

                          So to fix this I did the following changes:

                          UpdateTimer:
                          Code:
                                  void updatetimer_tick(object sender, System.Timers.ElapsedEventArgs e)
                                  {
                                      for (int i = 0; i < theHost.ScreenCount; i++)
                                      {
                                          // Get objects and info
                                          OMList sportslist = (OMList)manager[i]["sportslist"];
                                          string sport = (string)((OMLabel)manager[i]["currentscreen"]).Tag;
                                          string sportinfo = (string)((OMLabel)manager[i]["currentsubscreen"]).Tag;
                          
                                          // Update list
                                          SafeThread.Asynchronous(delegate() { fillsportslist(sportslist, sport, sportinfo); }, theHost);
                                      }
                                  }

                          fillsportslist:
                          Code:
                                  private void fillsportslist(OMList sportslist, string sport, string sportinfo)
                                  {
                                      //OMList sportslist = (OMList)manager[screen]["sportslist"];
                                      //OMLabel currentscreen = (OMLabel)manager[screen]["currentscreen"];
                                      //OMLabel currentsubscreen = (OMLabel)manager[screen]["currentsubscreen"];
                                      //string sport = Convert.ToString(currentscreen.Tag);
                                      //string sportinfo = Convert.ToString(currentsubscreen.Tag);
                                      sportslist.Clear();
                                      if ((sport == "NFL") && (sportinfo == "Game Info"))
                                      .....
                                      .....
                                      .....
                                  }
                          sportssubselectionlist_onclick:
                          Code:
                          SafeThread.Asynchronous(delegate() { fillsportslist((OMList)manager[screen]["sportslist"], (string)((OMLabel)manager[screen]["currentscreen"]).Tag, (string)((OMLabel)manager[screen]["currentsubscreen"]).Tag); }, theHost);

                          The above code gets the required listItem object and string info and then passes this along instead of the number that keeps changing.
                          The reason why these objects and data is not changing in the same manner as the number is that they are created in each increment right in front of where they are used.
                          Last edited by Borte; 08-26-2011, 05:42 PM. Reason: Typo...
                          Failure is not an option...
                          __________________________________________________ ______________________________
                          The only full multizone / multiscreen cross platform open source Front End -> OpenMobile

                          Comment


                          • #14
                            The changes work perfectly, exactly what I had in mind.

                            In your timer you have a for loop that passes the screen number (i) onto a new thread which calls fillsportslist. The problem is that when you create a new thread the screennumber (i) is changed in the meantime by the original timer thread that's running the for loop.
                            My thinking was, since i is an int, ex 1, it calls the thread and passes 1. That thread receives 1 for the int screen variable, and for running through this function screen was equal to 1? Maybe I confused myself, unless calling the threaded function with the int and continuing a loop is so micro-fast that it just bugs out? Not sure, but I thank you sooooo much for the help!!!
                            Current Worklog: TBA - '05 Rav4 (Mobo Dead).
                            www.rav4world.com - Forums for Rav4 owners
                            www.flavorfeasts.com - Cooking website/forums
                            -Basic forums live atm, come contribute!

                            Comment

                            Working...
                            X