Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18

Thread: Need help with C#

  1. #11
    Variable Bitrate
    Join Date
    Jul 2010
    Posts
    346
    Off the top of my head, I think this might be the fastest way. Just keep in mind this is not thread safe, nor possibly the best implementation...
    Code:
    System.Threading.Thread thread = new System.Threading.Thread(addressOf);
    thread.Start();
    
    private void addressOf()
    {
    }
    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. #12
    Maximum Bitrate
    Auto Apps:loading...
    VegasGuy's Avatar
    Join Date
    May 2009
    Location
    Las Vegas
    Posts
    598
    If you use the timer class in System.Threading ( System.Threading.Timer), that will execute on it's own thread. But as mentioned, it's not safe to manipulate the UI directly. System.windows.Forms.Timer executes on the UI thread, so it is safe to make changes to the UI in its methods.

    Mark

  3. #13
    Raw Wave pierrotm777's Avatar
    Join Date
    May 2008
    Location
    Bordeaux, France
    Posts
    2,843
    I have an issue with my sliders that i can't to move !
    This is my code:
    Code:
            #region Sliders
            /// <summary>
    		/// 
    		/// </summary>
    		/// <param name="SLD"></param>
    		/// <returns>-1 for not processed</returns>
    		public long ReturnSlider(ref string SLD)
    		{
                
                switch (SLD.ToLower())
                {
                    // SETTINGS
                    case "rrcoretemp_updatedelay":
                        return ((UpdateDelay) * 65535 / DelayMax);
    
                    case "rrcoretemp_maxtemp_alarm":
                        return ((CoreTempAlarm) * 65535 / CoreTempMax);
    
                }
                return -1;
    		}
    
            //*****************************************************************
            //* This Function will be called with requested slider code
            //* specified at the skin file. Simply return the value of the
            //* slider to be displayed. Values should range from 0 to 65535.
            //* It is also possible to intercept/change the slider code before
            //* it is processed in RideRunner (to overwrite existing codes).
            //*****************************************************************
            public long SetSlider(ref string SLD,ref int Value, ref bool Direction)
            {
                return -1;
                switch (SLD.ToLower())
                {
                    // SETTINGS
                    case "rrcoretemp_maxtemp_alarm":
                        CoreTempAlarm = (Value * CoreTempMax) / 65535;
    
                    case "rrcoretemp_updatedelay":
                        UpdateDelay = (Value * DelayMax) / 65535;
                }
            }
    Where is my error please ?

  4. #14
    Variable Bitrate
    Join Date
    Jul 2010
    Posts
    346
    In the second function, your returning -1 as the first line, thus no other code in the function has a chance to run. Not sure if that's the error/issue causing it not to work. If not, what error are you getting, or what line breaks for debugging?
    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!

  5. #15
    Raw Wave pierrotm777's Avatar
    Join Date
    May 2008
    Location
    Bordeaux, France
    Posts
    2,843
    In vb.net the sliders are defined as:
    Code:
        '*****************************************************************
        '* This Function will be called with requested slider code
        '* specified at the skin file. Simply return the value of the
        '* slider to be displayed. Values should range from 0 to 65536.
        '* It is also possible to intercept/change the slider code before
        '* it is processed in RideRunner (to overwrite existing codes).
        '*****************************************************************
        Public Function ReturnSlider(ByRef SLD As String) As Integer
    
            'This tells RR that the Slider was not processed in this plugin
            ReturnSlider = -1
    
            Select Case LCase(SLD)
    
                    ' SETTINGS
                Case "rr_p2140_setting_polldelay"
                    ReturnSlider = Math.Round((TempPluginSettings.PollDelay / 10) * 65535)
    
                Case "rr_p2140_setting_lowvbatt"
                    ReturnSlider = Math.Round((((TempPluginSettings.LowVbatt - 9) * 10) * 65535) / 20)
    
    
            End Select
    
        End Function
    
    
        '*****************************************************************
        '* This Function will be called with requested slider code
        '* specified at the skin file. Simply return the value of the
        '* slider to be displayed. Values should range from 0 to 65535.
        '* It is also possible to intercept/change the slider code before
        '* it is processed in RideRunner (to overwrite existing codes).
        '*****************************************************************
        Public Sub SetSlider(ByRef SLD As String, ByRef Value As Integer, ByRef Direction As Boolean)
    
            Select Case LCase(SLD)
                    ' SETTINGS
                Case "rr_p2140_setting_lowvbatt"
                    TempPluginSettings.LowVbatt = (Math.Round((Value * 20) / 65535) * 0.1) + 9
    
                Case "rr_p2140_setting_polldelay"
                    TempPluginSettings.PollDelay = Math.Round((Value * 10) / 65535)
    
    
            End Select
    
        End Sub

  6. #16
    Confusion Master
    Auto Apps:loading...
    Enforcer's Avatar
    Join Date
    Sep 2003
    Location
    If you go down to the woods today, You're sure of
    Posts
    14,625
    definitely remove the return =1 from the set slider routine. (it's not there in the VB6 example)


    in the first routine make the return=-1 a case else (I assume C has a case else statement) rather than where it currently is

  7. #17
    Maximum Bitrate
    Auto Apps:loading...
    VegasGuy's Avatar
    Join Date
    May 2009
    Location
    Las Vegas
    Posts
    598

    Arrow

    detlion1643 is correct. In the vb code, you assign a value to ReturnSlider, which is returned once all the relevant code in the function exits. In C# the "return" keyword exits the method immediately, preventing any further execution of code within the method. Try this:

    Code:
     public long SetSlider(ref string SLD,ref int Value, ref bool Direction)
            {
                 switch (SLD.ToLower())
                {
                    // SETTINGS
                    case "rrcoretemp_maxtemp_alarm":
                    {
                        CoreTempAlarm = (Value * CoreTempMax) / 65535;
                        return CoreTempAlarm;
                    }
                    case "rrcoretemp_updatedelay":
                    {
                        UpdateDelay = (Value * DelayMax) / 65535;
                        return UpdateDelay;
                    }
                }
                return -1;
    
            }
    P.S. you don't need the "ref" keyword here, since you are not changing the values being referenced. You're only using them in calculations within the method. Also, you're not using the "direction" Boolean at all, so it's unnecessary.

    Mark
    Last edited by VegasGuy; 10-05-2012 at 11:24 AM.

  8. #18
    Raw Wave pierrotm777's Avatar
    Join Date
    May 2008
    Location
    Bordeaux, France
    Posts
    2,843
    Cool,
    Greats thanks VegasGuy that run very well now !!!
    Thanks all guys also !!!

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •