Results 1 to 22 of 22

Thread: Timers max interval?

  1. #1

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729

    Timers max interval?

    what is the max amount of time that a timer can have in its interval in .NET?
    \m/\m/

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    It accepts Int32 type which means :
    it shouldn't exceed this range (2147483647)

  3. #3

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    hmm that long? are u sure? i remember that in vb6 timers interval was a long value but even there it had a limit inferior to long's value limit i think..or not?!
    \m/\m/

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    lol , timers for not more that 1hour at most ! What the hell are you ganna profit from so ??

  5. #5

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    hmm well... i have an app that will try to connect to another app over a network, in case it doest make it he will try in X time that will be defined by the client, and in the most cases should be something like 30min to 2h..thats why i made that question lol
    \m/\m/

  6. #6
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Why you don't go for threading since it's most suitable for such environement !!

  7. #7

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    threading? i want it to connect from X time to X time it has nothing to do with threading lol

    edit: or not?
    \m/\m/

  8. #8
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    lol , no need buddy , connection obj has timeout method that calculates the connection availability.

  9. #9

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    AHHH GOOD IDEIA let me check it
    \m/\m/

  10. #10
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    One more thing about threading I forgot to mention is : it has pause and resuem methods which is much more efficient than timers .

  11. #11

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    well actually i am using a third-party class dll and it doesnt seem to have the connection-timeout thing...and why should i use threading? i really dont get it..i have the ideia that putting this app with more threads will just turn it to more complex with no reason..maybe i should use gettickcount(or time i dont remember exactly) to do that?

    otherwise using threads what was ur idea? create a thread and then stop it and resume it?
    \m/\m/

  12. #12
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    It's not complex nor hard to manage . I posted a sample , see how simple it works !!
    Read more about threading here...
    Attached Files Attached Files

  13. #13
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Sleep method , can sleep for seconds , minutes , even days plus it accepts timespan .
    You can give your threads high priority to be executed immediately after system threads . It can be suspended (just like system hibernation) . It's really really boosts your program performance !

    Hope that helps !

  14. #14

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    i dont get it. i have a thread1 that calls the CONNECT() sub.

    the sub tries to connect but cant connect..then how would it be able to wait the x time? notice how the connect() is about to finish because it has no more code left..and i dont want to make a recursive call to the function itself because that would suck
    \m/\m/

  15. #15

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    ok now i think i understood what u mean..the connect() has a loop inside it and in the finish of the loop body has a thread.sleep()
    \m/\m/

  16. #16
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Sleep is used only if you're going to run that thread again , rather you can use Abort method (after successful connection).

  17. #17

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    wow did it although i had to do that with recursion to the own function because the only way to know when the connection failed is thru catching the exception:
    code(in C#):
    Code:
    		private void Connect(object sender, System.EventArgs e) {
    			Thread connectThread = new Thread(new ThreadStart(Connect2));
    			connectThread.Name = "ConnectThread";
    			connectThread.Start();
    		}
    
    		private void Connect2() {
    			try {
    				if (button1.Text == CONNECT) {
    					l1.Write("connecting to the other computer...", true, true);
    					Client.Connect(ip.Text, int.Parse(port.Text));
    					button1.Text = DISCONNECT;
    					button1.Enabled = false;
    				}
    				else {
    					Client.Close(false);
    					l1.Write("connection stoped by user", true, true);
    					button1.Text = CONNECT;
    				}
    			}
    			catch (Exception err) {
    				l1.Error(err.Message);
    				button1.Enabled = true;
    
    				Thread.Sleep((int)numericUpDown1.Value * 1000);
    
    				if (checkBox3.Checked) {
    					this.Connect2();
    				}
    			}
    		}
    Last edited by PT Exorcist; Apr 6th, 2003 at 04:46 PM.
    \m/\m/

  18. #18
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I can't understand the text between quotations !!!!

  19. #19

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    edited them
    \m/\m/

  20. #20
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Hmm, it looks different than the regular connection objs we use in .NET . Why don't you use SQL or OLEDB objs . They have more options like (timeout , connectionstate, ... etc ) , they return wheather the conntions is successful or failed?

  21. #21

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    hmm i dont undestand..this is socket connection!
    \m/\m/

  22. #22
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Oh yeah , I though you're connection to a database !lol

Posting Permissions

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



Click Here to Expand Forum to Full Width