Click here to Skip to main content
15,888,116 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to select 1 row with 2 items from listbox to use them in method every 1min like exmple

here i add 2 items in 1 row

C#
Uniqueslist.Items.Add(string.Format("{0} , {1}", MobIDTextUnq.Text, MobCntTextUnq.Text));


and i want to use this 2 items in this method every 1min

C#
public static void Loadmonster(int MobID,int Cont)
{
    DateTime time = System.DateTime.Now;
    time.ToLongTimeString();

    try
    {
        Packet packet = new Packet((ushort)Opcode.CLIENT_OPCODES.CLIENT_GM, true); //GM command
        packet.WriteUInt8((byte)6); //Loadmonster
        packet.WriteUInt8((byte)0);
        packet.WriteUInt32(MobID); // ID . mobs 22519
        packet.WriteUInt8(Cont); //No. of mobs 1
        packet.WriteUInt8((byte)3); //static
        Agent.Send(packet);
        CodeWindow.Logs.Items.Add("[" + time + "] : Loadmonster Done.");
    }

   catch
   {
   }
}



i think it's by loop but i don't know how to do this and i want if this like exmple 1 row selected never select it again and select the next row and never back again i hope someone help me with this problem .
Posted
Updated 2-Sep-16 1:44am
v2

1 solution

If you want to do something at a regular interval such as "every minute" then either user a Timer or a separate thread. A timer will probably be more use in this case as you need access to you controls, which requires you to be on the UI thread.
There are a few different Timer classes you could use:
Timer Class (System.Timers)[^]
Timer Class (System.Threading)[^]
Timer Class (System.Windows.Forms)[^]
Which one you want to use will depend on the environment you are working in.
 
Share this answer
 
Comments
C Amr Moneim 2-Sep-16 8:27am    
before i use time how i can use this 2 items from listbox in method
PureNsanity 2-Sep-16 13:01pm    
Don't forget the Observable.Interval. If you're using Rx anyway I feel it's the optimal choice.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900