|
Cool. :P
“Time and space can be a bitch.”
–Gushie, Quantum Leap
{o,o}.oO( Looking for a great RSS reader? Try FeedBeast! )
|)””’) Built with home-grown CodeProject components!
-”-”-
|
|
|
|
|
As the others suggested, the answer is to stop the actual simulation from taking place by means of something like an internal variable or a timer setting. Simply freezing the application will cause Windows to think it has hung, and which will display the unresponsive program dialog (which I am guessing is what you are calling "crashing"). It will also not allow you to unfreeze it again later.
You might also look into performing the simulation on a separate thread (though remember you will still have to update the picturebox on the main thread), because then you will just be able to pause and resume the simulation thread at will, and without chewing up CPU cycles in an infinite loop.
“Time and space can be a bitch.”
–Gushie, Quantum Leap
{o,o}.oO( Looking for a great RSS reader? Try FeedBeast! )
|)””’) Built with home-grown CodeProject components!
-”-”-
|
|
|
|
|
But how can I do this in this code?
[code]
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
// opvragen van de burst die momenteel gedaan is
// dit kan via een methode in de Controller te steken
// die controlleerd welke knop (FCFS-SJF) ingedrukt werd
// in deze klasse wordt er dan gekeken naar de eindeburst
// Dat moet dan doorgestuurd worden naar hier.
Graphics g = e.Graphics;
String algoritme = cmbSchedule.SelectedItem.ToString();
int burstlengte = 0;
switch (algoritme)
{
case "FCFS": //burstlengte = Controller.GetInstance(ProcessList).Simulatie(ProcessList[0].lijstvanBursts[0]);
burstlengte = Controller.GetInstance(ProcessList).Hoeveelburst(ProcessList[0].lijstvanBursts[0].Lengte);
foreach (Proces p in ProcessList)
{
foreach (Burst b in p.lijstvanBursts)
{
if (Controller.GetInstance(ProcessList).Teller > p.PAankomst + b.Lengte)
{
// No simulation anymore
//burstlengte = 0;
//pictureBox1.Update();
}
//do
//{
// eind();
//} while (Controller.GetInstance(ProcessList).Teller > (p.PAankomst + b.Lengte) || Controller.GetInstance(ProcessList).Teller == (p.PAankomst + b.Lengte));
}
}
break;
case "SJF": //burstlengte = SJF.getInstance().GeordendeLijst[0].lijstvanBursts[0].Lengte;
//burstlengte = Controller.GetInstance(ProcessList).Hoeveelburst(SJF.getInstance().GeordendeLijst[0].lijstvanBursts[0].Lengte);
break;
}
// Laat de simulatie niet verder gaan als de burst gedaan is
//if (Controller.GetInstance(ProcessList).Teller > burstlengte + ProcessList[0].PAankomst)
//{
// burstlengte = 0;
//}
//int burstlengte = Controller.GetInstance(ProcessList).Simulatie(ProcessList[0].lijstvanBursts[0]);
g.SmoothingMode = SmoothingMode.AntiAlias;
Rectangle rect = new Rectangle(20, 20, burstlengte , 100);
Pen redPen = new Pen(Color.Red, 3);
g.FillRectangle(Brushes.Red, 25, 20, burstlengte , 100);
//Graphics g = e.Graphics;
//foreach (Proces p1 in lbProcessName.Items)
//{
// foreach (Burst b in p1.lijstvanBursts)
// {
// int burstlengte = Controller.GetInstance(ProcesList).Simulatie(b);
// g.SmoothingMode = SmoothingMode.AntiAlias;
// Rectangle rect = new Rectangle(20, 20, burstlengte * 2, 100);
// Pen redPen = new Pen(Color.Red, 3);
// g.FillRectangle(Brushes.Red, 25, 20, burstlengte * 2, 100);
// }
//}
}
private void eind()
{ }
[/code]
|
|
|
|
|
First of all, move all of that outside of PictureBox.Paint and into a separate thread that modifies a shared (synchronized) bitmap image. Then run the above and either send events to the main thread to update the picture box with the current state of the bitmap at various intervals, or do this on a timer. Just be sure to use lock() before accessing the shared bitmap on either thread.
In PictureBox.Paint just draw the shared bitmap to the PictureBox.
Now when you pause the simulation, the picturebox should no longer receive signals to update, or if you put it on a separate timer, you should also pause that timer when you pause the simulation.
Logan
“Time and space can be a bitch.”
–Gushie, Quantum Leap
{o,o}.oO( Looking for a great RSS reader? Try FeedBeast! )
|)””’) Built with home-grown CodeProject components!
-”-”-
|
|
|
|
|
I have one multiline textbox. I want to open Microsoft word and write textbox contents on MS word.
One more thing : I want to write DataGridview Table onto MS ecxel sheet.
???
thanx in advance....
|
|
|
|
|
You need to use MS Office Interops
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
I want a toasted cheese sandwich but sometimes we can't always have what we want.
Look up the interops like t'other member said, and then if you get stuck you can ask about the specific problem you are having and people will be happy to help.
My current favourite word is: I'm starting to run out of fav. words!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
Thanks for quick reply...
Problem of MS Word from C# has been done.
Now i want to Write Tabular data from DataGridView to MS Excel Sheet.
I want Excel sheet also in Tabular format.
Opening of Excel sheet and writing data into it, has also been done.
But format of DataGridView into Excel sheet is not coming.
|
|
|
|
|
Hi,
How can I reach database relation diagram of sql by using smo? I want to learn parent key table of any column if that column is foreign key.
Forexample, in northwind database, in products table, there is categoryid column. This column is related to id in Category table. I want to find this.
Best Regards
THANKS
|
|
|
|
|
It is really rude to repost everywhere.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Hi..
I want to increment/dercrement the selected Value in the datetimepicker using keys like a to z.. if i press A it should increment the value by 1, if i press B it should decrement the value by 1.
can anyone help me plz..
thanks & regards
vinayskvs
modified on Wednesday, August 27, 2008 8:03 AM
|
|
|
|
|
Hello Everybody,
How can we create a class using ComClass Template.
First of all, I am not able to add the reference of Microsoft.Build.Tasks.V3.5 since it is not being listed out in the Add Reference dialog. So I browsed this dll and added the reference.
Still my problem is not solved. I am getting the following error.
'Microsoft.Build.Tasks.Deployment.ManifestUtilities.ComClass' is not an attribute class
I am not sure.
Here is my code,
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Build.Tasks.Deployment.ManifestUtilities;
namespace COMArray
{
[ComClass(ComClass2.ClassId, ComClass2.InterfaceId, ComClass2.EventsId)]
public class ComClass2
{
#region "COM GUIDs"
public const string ClassId = "83a8275f-9282-4257-ba62-afab6ed03beb";
public const string InterfaceId = "e75a1569-f1aa-4bdc-8e39-ae5807ee5baa";
public const string EventsId = "f966bdd3-9c5b-4ad9-8714-bc17d28f7e3a";
#endregion
public ComClass2()
: base()
{
}
private int _test;
public int test
{
get { return _test; }
set { _test = value; }
}
}
[ComClass(ComClass1.ClassId, ComClass1.InterfaceId, ComClass1.EventsId)]
public class ComClass1
{
#region "COM GUIDs"
public const string ClassId = "35cf06df-5ed3-431f-9780-1e30d8acb94c";
public const string InterfaceId = "04fcc0fb-da33-4750-bab1-86e3b6d0e300";
public const string EventsId = "e073bca9-3bc5-437a-8c77-a489086c6517";
#endregion
public ComClass1()
: base()
{
}
private ComClass2[] t;
public ComClass2[] myFunction()
{
t(0) = new ComClass2();
t(1) = new ComClass2();
t(0).test = 111;
t(1).test = 222;
return t;
}
}
}
Am I on track? Am I using the ComClass properly.Can anybody guide me through the ComClass attribute usage? I just want to create a class using ComClass Template.
Any help is greatly appreciated.
Cheers,
Saran
|
|
|
|
|
Hi everybody
i want to change machain datetime ,but i dont how
thanks for help
MD_NADA
|
|
|
|
|
md_nada wrote: i want to change machain datetime ,but i dont how
Follow the following steps:
1. Open Notepad
2. Go to Format->Font. Select your favourite font.
3. Look at the time on the Wall Clock at your home/office and write it in on the NotePad.
4. Save the file at C:\ drive with name currenttime.txt.
Or did you expect any other answer
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
hi maybe i was not clear , i mean change machain date programaticlly
using C#
MD_NADA
|
|
|
|
|
see the extreme bottom-right of your computer screen(where the system time is displayed),double click the system time being displayed...and make the changes
|
|
|
|
|
|
thnx for ur help
but i try this code but it dosent work
MD_NADA
|
|
|
|
|
There is a little fix :
correct solution
public class Win32
{
private Win32()
{
}
[StructLayout(LayoutKind.Sequential)]
public struct SystemTime
{
[MarshalAs(UnmanagedType.U2)]
public short Year;
[MarshalAs(UnmanagedType.U2)]
public short Month;
[MarshalAs(UnmanagedType.U2)]
public short DayOfWeek;
[MarshalAs(UnmanagedType.U2)]
public short Day;
[MarshalAs(UnmanagedType.U2)]
public short Hour;
[MarshalAs(UnmanagedType.U2)]
public short Minute;
[MarshalAs(UnmanagedType.U2)]
public short Second;
[MarshalAs(UnmanagedType.U2)]
public short Milliseconds;
}
[DllImport("kernel32.dll")]
public static extern void GetLocalTime(
out SystemTime systemTime);
[DllImport("kernel32.dll")]
public static extern void GetSystemTime(
out SystemTime systemTime);
[DllImport("kernel32.dll")]
public static extern bool SetSystemTime(
ref SystemTime systemTime);
[DllImport("kernel32.dll")]
public static extern bool SetLocalTime(
ref SystemTime systemTime);
}
....
in you method do this :
Win32.SystemTime sysTime;
sysTime.Day = 13;
Win32.SetSystemTime(ref sysTime);
Make sure that you got admin rights.
|
|
|
|
|
Hi!
Is it possible to have two instances of a classes which both instances share the same base class instance?
For example:
class Program
{
static void Main(string[] args)
{
Bar bar1 = new Bar();
Bar bar2 = new Bar();
}
}
class Foe
{
}
class Bar : Foe
{
}
Is this possible to get the instanees bar1 and bar2 to share the same base instance?
/Mc_Topaz!
|
|
|
|
|
Mc_Topaz wrote: Is this possible to get the instanees bar1 and bar2 to share the same base instance?
What is your meaning with SHARE?
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
huh
sorry i dont understand
|
|
|
|
|
Hello...
Your example code is pretty perfect and will work for sure.
Still I dont understand what you are trying to ask.
Cheers,
Saran
|
|
|
|
|
I'm a bit unsure that you are asking here. Are you asking whether you can have two classes which are the same instance, i.e. using a Singleton pattern?
|
|
|
|
|
Well, I shall try to explain what I mean by replying to my own post.
When I create a instance for the Bar class, the code will automatically create an instance in the Foe class.
So I have one Bar instance and also one Foe instance. Let's call the Bar class instance: bar1.
Later I would like one more instance of the Bar class: bar2. But in this case, I don't want a brand new instance of the Foe class.
Instead I want bar2 to have the same foe instance as bar1 have.
Is this possible?
I hope I explained it better this time.
|
|
|
|