|
Hi!
Just use the modulo operator % .
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Divide your number with 2 using % operator and if your answer is not zeor than the number is odd else it is even
|
|
|
|
|
|
Hi i want to develop a profiling tool. I just need to add TRACE to a .net assembly's(exe or dll) all methods before its execution.
is it possible to modify the assembly by inserting code for trace?
My small attempt...
|
|
|
|
|
Is there a way to print word docs (without a preview) using word automation?
John
|
|
|
|
|
Hello,all:
I am using ArcEngine(a software managing spatial data) to upload data(shapefile etc.) to database.Because the process of uploading data is time-consuming,when I click the ProgressBar window or minimize the parent window and then maximize the parent window,the parent window and the ProgressBar window is white using single thread.
So,I use multithread to work out this prolem,and it does.But,the speed of uploading data to database slows down greatly . The work uploading data is no more than 10 minutes in single thread,but 40 minutes in multithread!!
Who can help me?I appreciate your help!
private delegate bool UpdateHandle(int nValue,string text);
private UpdateHandle myUpdate = null;
myProcessBar is a Window has two controls,a ProgressBar named Bar and a Label named LabelInfo.It has a public method
BeeUpdate(int value, string text)
public bool BeeUpdate(int value, string text)
{
LabelInfo.Text = text;
LabelInfo.Refresh();
if (value > 0)
{
if (Bar.Value + value < Bar.Maximum)
{
Bar.Value += value;
Bar.Refresh();
return true;
}
else
{
Bar.Value = Bar.Maximum;
Bar.Refresh();
this.Close();
return false;
}
}
return false;
}
the delegate entry point:
private void ShowProcessBar()
{
myProcessBar = new ProgressBee("Uploading", 100 * ClassCount);
myUpdate = new UpdateHandle(myProcessBar.BeeUpdate);
myProcessBar.ShowDialog();
myProcessBar = null;
}
the method called by MainWindow
public bool CopyTo(parm1, parm2,Form caller)
{
MethodInvoker mi = new MethodInvoker(ShowProcessBar);
mi.BeginInvoke(null, null);
caller.BeginInvoke(mi);
Thread.Sleep(2000);
Thread copyProcess = new Thread(delegate()
{
for (int i = 0; i < FeatureClassCount; i++)
{
Thread.Sleep(30);
if (condition)
{
}
else
{
}
caller.Invoke(this.myUpdate, new object[] { 100, "……" });
}
});
copyProcess.Priority = ThreadPriority.AboveNormal;
copyProcess.Start();
return true;
}
|
|
|
|
|
Threads don't speed things up. They slow them down, by causing your UI thread to also take process time. Having said that, what is your UI doing to use up that much time ?
Nothend wrote: Thread.Sleep(30);
Why force a sleep in a process that is already slow ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I'm Trying to Build a Project Manager Form within an MDI application that I've already made. I have the Form Set up, but I'm having problems making it work. What I want to do is Make it so that the user click on a button in the main form and it adds a Task to either a list view or a grid view in the Project Form. Then I want the project form to take the task data and put it into the chart that i have. Each task will show up as an independent series and the start date will mark the start point, the finish date will mark the end point of the series on the char.
As of right now, I don't care for making the Chart work (that will come later). What I want to know is how to make a Grid View or List View control work to display the Project Management Data and how to save that data in a file to be loaded up again.
|
|
|
|
|
I am writing my first Windows programs. I have a welcome form which invokes another form which invokes another form etc.
I want to read data from a data file, store it into a list, and have the contents of the list available to all other forms (code).
If this was one file C++ program , I could choose to declare the list globally (at the top of the file) or to pass the list as parameter to the other functions. However, with all these generated form files, i am a bit confused as how to accomplish the same effect in c#.
Could someone point me in the right direction
|
|
|
|
|
Well, you could make the list static and public in one of the classes, and then get it by using className.myList but er, that wouldn't be very good really.
Or, you could pass the list to each form via its constructor (so when you create the form you'd go myForm = new Form(myList); ) and so each form would have access to the list.
Another route might be to create a singleton class and put the list in that. Then whenever you need to access it, you can just get the instance of the class and get to the list from there.
And a link on singleton classes if you have not encountered them before: clicky[^]
There's probably another way, but i grow weary of typing, and must sleep
My current favourite word is: Bacon!
-SK Genius
|
|
|
|
|
One technique would be for the subforms to accept the list as a parameter to their constructors, then the calling form would pass the list when it constructs the subforms.
Another would be for the subforms to have a Property to accept the list, and the calling form could instantiate the subform, set the Property, then show the form.
There is no reason why any two cats should be skinned the same way.
|
|
|
|
|
In C#, I would have the list stored somewhere, and then use delegates to access it in other forms, I'd avoid having globals if I could help it ( I avoided it in C++ as well )
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I'm trying to paint some extra info on to a rtb control and the only way to do so is by setting ControlStyles.UserPaint to true so the Paint method gets called, but slight problem since its all user drawn the text doesn't get drawn How do i get around this?
Thanks
|
|
|
|
|
You could call the base OnPaint method from your code.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
When i call the base.OnPaint method it throws an error, and when i single step through it once the base.OnPaint method is called it loops back to the begining of my Paint handler. Im guessing this is because ControlStyles.UserPaint is set to true but that is the only way the rich text box will allow any paint handlers to be called.
|
|
|
|
|
I would like to capture POST data from a local web form displayed in a .NET WebBrowser control.
In activeX browser you can use the "BeforeNavigate2 event" to capture POST data and the entire HTML header, but I only see the cancel flag and target frame name in the .NET 2.0 control.
Does anyone know how to capture this data in .NET?
|
|
|
|
|
HI,
Win32 Class Example : Win32_BIOS
is there any way to get the list of those classes
from the system (not manually)
Have Fun
Never forget it
|
|
|
|
|
Is this a C# class ? If so, you can use reflection. If not, then no.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
THANKS
Have Fun
Never forget it
|
|
|
|
|
That's a WMI class. You'd have to use WMI methods, and the .NET BCL System.Managment namespace classes to do this. I can't remember how, because I haven't done it in about 10 years, but it is possible to do. CIM_Studio does the exact same thing.
|
|
|
|
|
THANKS
Have Fun
Never forget it
|
|
|
|
|
We have several embedded resources file in XML format that can be loaded at runtime. The UI is a WPF application. When these files area loaded, it constructs objects via the XmlSerializer, and those resulting objects are used to make little boxes float around a 3D window for a simulation. At some point when adding, the application appears to hang. Alright... That's happened to me a-plenty, but it throws absolutely no exception and I don't get the "Not Responding" notification. Another interesting observation is that after the hang, when the mouse is put over the app window, the control boxes flash like a rapid hover-over. When I break into the debugger (btw I have the IDE to break on all thrown exceptions) I can see where the app stops, but no data is available because the IDE reports that the executing thread is in a sleep or join state.
I guess the question is how can I detect when the Dispatcher Thread takes a dirt nap? Is there a way to appoint a new thread to watch it and restart?
Scott
"Run for your life from any man who tells you that money is evil. That sentence is the leper's bell of an approaching looter." --Ayn Rand
|
|
|
|
|
After dealing with this for two days, we found the issue. The coordinates for the floating boxes are calculated with respect to time in a wrapped timer. We changed the internal timer of that class to be a DispatchTimer and now everything seems fine... Thanks to those that took the time to read this.
"Run for your life from any man who tells you that money is evil. That sentence is the leper's bell of an approaching looter." --Ayn Rand
|
|
|
|
|
Just out of curiosity.
how does WPF deal with gui elements and threads?
is it the same as winforms idea?
"only the main thread should interact with gui elements, other threads have to marshal calls to the main thread"
or can threads create / interact with wpf elements freely?
|
|
|
|
|
From what I've read, WPF assigns 2 threads at the start, a Render thread and a Dispatcher thread. The Render thread does the background work, while the Dispatcher thread does the work of maintain the GUI. Any explanation I give you won't be as good as this on MSDN[^]
Scott
"Run for your life from any man who tells you that money is evil. That sentence is the leper's bell of an approaching looter." --Ayn Rand
|
|
|
|