Click to See Complete Forum and Search --> : Problems in mutiple instances of form
leoiser
July 2nd, 2007, 03:12 AM
Hi all,
I am creating multiple instance of a Form(let it be Form1).Actually Form1 having 4 panel.Each one having diffrent task.One panel showing picture,another calling web service & displying data.In Form1 I am having a control(like marquee,text is drawing using timer).But running different instances of form marquee is stopping for a while.Calling webservice cause the problem.In each form instances I ve the marquee.If I run first instance have the picture and marquee,second instance will access web service,so that time,both forms marquee is stopping at the same time when a call to Webservice happen. What I ve to do to solve this issue.Thanks in advance.
With reagrds,
leo
Shuja Ali
July 2nd, 2007, 03:15 AM
Welcome to the Forum :wave:
Seems like you are using Timers? If that is the case try using System.Threading.Timer. And another option would be to use MultiThreading.
leoiser
July 2nd, 2007, 04:10 AM
For the marquee, I created a another class library project and using system.timer.,interval is 15
in my form (form1) in each 10 seconds my panel is refreshing using System.Forms.Timer,
so while refreshing it will call the webservie & displaying the values to the lables.
I noticed that while displaying to the lablel the delay is occuring.Here I am giving the
sample code(logic).Please advice.Thanks
Private void LoadFromWS()
{
//Getting data from web service & storing it in array
ws.display obj = new ws.display();
Arrshows = obj.getData(DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt"));
}
Private void display()
{
//Displaying 5 at a time for 10 seconds
//Using system.Forms.Timer
lable1.text = Arrshows[intIndex];
lable2.text = Arrshows[++intIndex];
lable3.text = Arrshows[++intIndex];
lable4.text = Arrshows[++intIndex];
lable5.text = Arrshows[++intIndex];
//checking intIndex > Arrshows.lenght() then intIndex =0 & return;
}
private timer1_tick()
{
display();
}
Please advice with the code.sorry I am not good in threading....Thanks
leo
Shuja Ali
July 2nd, 2007, 04:54 AM
I would still suggest using Multi Threading in your case. If you are using .NET 2.0 then take a look at BackGroundWorker Component. That will help you in resolving issues with your UI.
Also when you post code, please use code tags like this
your code here
leoiser
July 2nd, 2007, 06:07 AM
I would still suggest using Multi Threading in your case. If you are using .NET 2.0 then take a look at BackGroundWorker Component. That will help you in resolving issues with your UI.
Also when you post code, please use code tags like this
your code here
Hi shuja,
Please suggest how to arrange the code using multithreading...Actually marquee control is placed in my form.I put the displaying code like this
//DisplayNextScreen(); //is displaying the values in lable, I put the thread
System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(InfoMessage));
t.IsBackground = true;
t.Start();
------------------------------------
delegate void Del_DisplayNextScreen();
public void InfoMessage()
{
if (this.InvokeRequired)
{
Del_DisplayNextSession method = new Del_DisplayNextScreen(InfoMessage);
this.Invoke(method, new object[] { });
return;
}
DisplayNextScreen();
}
------------------------------------
But the same problem still existing..
Pls advice.Thanks
Shuja Ali
July 2nd, 2007, 06:13 AM
My first suggestion was to use System.Threading.Timer. You are still using Forms.Timers.
leoiser
July 2nd, 2007, 11:46 PM
My first suggestion was to use System.Threading.Timer. You are still using Forms.Timers.
I Change the code to System.Threading.Timer, first it got error that Illegal Cross Thread Calls exception at Scroll control, then I added in scroll Control code
Control.CheckForIllegalCrossThreadCalls = false;
now some what better.little delay (fraction of second) is there.The previous code I put in the scroll control is write or not ? pls advice...
Thanks in advance.
Mutant_Fruit
July 3rd, 2007, 01:42 AM
The exception was being throw for a reason. You need to look up how to use Form.Invoke correctly.
leoiser
July 3rd, 2007, 04:03 AM
my head is spinning...when loading a panel with more controls,the scroll control having a fast forward effect...(means running fast) .please check the below code(loading web service)
System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(LoadWS_NextSession));
t.IsBackground = true;
t.Start();
t.Join();
t.Abort();
it means the control is running at the backgroud..is it? I ve no idea...pls help
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.