|
that's interesting, thanks. I unfortunately got an exception saying not enough arguments were supplied so I added in my arguments for the delegates like this:
_statusbar.Owner.Invoke((ThreadEvent)delegate
{
_statusbar.Text = "test test, started work";
}, new Object[] { this, ThreadEventArgs("test message", 0, TheadStatusType.thread_started) });
In my original delegate, I had it declared object, ThreadEventArgs so I guess that's what it wanted.
This works, and without the form-side needing a delegate. Is that the best though? With it like this, it requires a status bar to exist in order to work. I liked the idea of triggering an event and the form can receive it if it wants to and deal with it as it sees fit.
|
|
|
|
|
I think I found the problem with what I was doing originally, I don't think I was invoking the delegate right. I ran across this page which talks about BeginInvoke. I used the section of code declared as the typical way of using BeginInvoke as my inspiration and got my invoke working pretty well.
I thought anyone reading this and interested in a fix might want to know.
|
|
|
|
|
Like I said, BackgroundWorker is really want you should look at:
backgroundWorker1.DoWork += MyWorkerFunction;
backgroundWorker1.ProgressChanged += MyProgressReported;
backgroundWorker1.RunWorkerCompleted += MyWorkCompleted;
backgroundWorker1.RunAsync(someArgument);
void MyWorkerFunction(object sender, DoWorkEventArgs e)
{
...
backgroundWorker1.ReportProgress(99);
...
}
void MyProgressReported(object sender, ProgressReportedEventArgs e)
{
}
void MyWorkCompleted(object sender, RunWorkerCompletedEventArgs e)
{
}
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Connor's Christmas Spectacular!
Judah Himango
|
|
|
|
|
I looked at BackgroundWorker after you said it and concluded that using it would require a lot of rewiring of my program, more than I was willing to do. However, I do now know it exists and I'll keep it in mind next time around.
|
|
|
|
|
Hy,
I need some tools (classes not exe) to export/transform some text(reports) in XLS, HTML, PDF, DBF, XML... format.
Tranks,
Mihai
|
|
|
|
|
Hello,
I want to use weather reports in my project.
Is anybody know a web service that provides weather reports??
|
|
|
|
|
|
Hi...
I have a Panel, and want to add a line on it. But i want the line to be drawn over time, using a timer.
But i don't know how to do that, I have drawn the first part of the line using this code:
private void panel1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
e.Graphics.DrawLine(new Pen(Color.Black), new Point(0,0), new Point(15,15));
}
This gives me a line from the top corner. But then the timer make the first tick i want it to continue draw the line, so the next pont will be from (15,15) to (30,30) and so on as the timer counts.
Can anyone tell me how to do, and/or give me some articles about drawing with C#?
Thanks
QzRz
|
|
|
|
|
Store the size of the line in a variable, and use that to draw the line in paint event. In the timer event you change the value of the variable and invalidate the panel, that will cause a redraw.
---
b { font-weight: normal; }
|
|
|
|
|
i am doing a Shopping Cart Application
After registration process all users will get a unique 16 digit code like,
(XXXX-XXXX-XXXX-XXXX) he can distribute this code to his friends where they get some percent discount by using this Code.
Now my problem is how to generate 16 digit Strong Unique Code
Please send the complete code to generate 16 digit Random Number using C#
Waiting for your help.
With Regards
Satisha
|
|
|
|
|
Does it have to be 16 digits? Why not just use a Guid ?
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
|
Complete code? Why? Can't you write any of the code yourself?
Here is how you create a random number between 0 and 9999 and convert it into a four digit string:
Random r = new Random();<br />
string x = r.Next(10000).ToString("0000");
That's the tricky part. That should get you far enough to very easily put together a 16 digit code.
---
b { font-weight: normal; }
|
|
|
|
|
Does it have to be one-way or can it be a reversible operation? (Like: Is the ID a secret?)
I'd use some hash.
Cheers,
Sebastian
--
Contra vim mortem non est medicamen in hortem.
|
|
|
|
|
hi everybody,
i want to know how to menage the optimistic cuncurrency using timestamp.
i've already added a column for every table (timestamp type).
how i can modify the Update command to use it?
(im using C# 2005)
Thank you in advance
Enrico
VentoEngine corp.
Program your life ^^
|
|
|
|
|
In the c# programming guide it list several descriptions of a data type. One description is the "user-defined data type". And examples given are: class or interface.
What are some other user-defined data types?
|
|
|
|
|
|
Is there any way of keeping count of the number of forms in a Visual C# WindowsApplication Project. I need to create a program which can be executed off a button in the VS IDE which will pop a message box that will keep track of the number of forms in the currently opened project in the VS IDE.
|
|
|
|
|
How do i create and integrate a toolbar into the Visual Studio .NET 2005 IDE using C#. The extensibility projects provide me with Addins which allow for the creation of buttons, but what about a full-fledged toolbar.
|
|
|
|
|
Holla,
I got a little problem here: I am developing this "little helper" under VS2003 and .NET1.1. I want to change the application's size in code (implementing a "show some/show all" toggle that also creates/disposes an "advanced options"-panel.)
I KNOW that I did this before, but I cannot figure out while it wont work now:
I currently have a button and in the click-handler I change the forms size as follows:
this.Size = new Size(300,400); // or
this.Width = 300;
this.Height = 400;
// and afterward, I get rid of the advanced panel.
doSomePanelHidingStuff();
According to the MSDN, that should be all thats necessary. When this didnt work, I tried some combinations of invalidating and refreshing the form, to no avail. I added the "refreshing" to a resize-event handler.
Whatever I do, the form's size wont change.
Any hints?
Cheers,
Sebastian
--
Contra vim mortem non est medicamen in hortem.
|
|
|
|
|
Perhaps you have setted a maximum size for your form.
The attempt to change the forms size to a value larger than the one found in MaximumSize will fail...
protected internal static readonly ... and I wish the list could continue ...
|
|
|
|
|
Actually, the size I am trying to change to varies.
No max-size, no min-size. The form wouldnt make much sense at a low-size, so I am calculating the new sizes.
If I switch from the "normal" form to the "advanced" form, the new size is oldsize + oldsize / 2, rounded to the next integer that is a multiple of three.
To scale down, the new size is the old size * 2/3, rounded to the next even integer.
That size calculation is independant of the size setting and I checked the result via stdout and debugger. The size is set correctly, but the form wont refresh to the new size.
Cheers,
Sebastian
--
Contra vim mortem non est medicamen in hortem.
|
|
|
|
|
Usualy a managed form should change it's size when the width and/or heigth is changed...
But on special cases this operation is canceled :
- as I said in my initial post, if the form's MaximumSize is setted to a value smaller than the new size
- if you override the form's WndProc and ignore the WM_RESIZE message
These are possile cases that may stop your correct written code to resize a form.
If none of this applies check you code ... step by step it with the debugger and check if you do the correct thing.
protected internal static readonly ... and I wish the list could continue ...
|
|
|
|
|
The string class in .Net (just as anyother classes) inherits from object . Object class has a static method ReferenceEquals which takes two parameters and returns true if both are referenced to the same value in the heap.
So in my code below,
<br />
string s1 = "ABC";<br />
string s2 = s1;<br />
<br />
string s3 = "ABC";<br />
string s4 = "ABC";<br />
I was expecting the S3 and S4 to have separate references. I may be answering my own questio here .. but if the string is intered then the second variable is pointed to the memory refernece of the original value. How can I differentiate if the S4 is not an actual refernece to S3?
- Malhar
-- modified at 10:40 Monday 6th February, 2006
|
|
|
|
|
The thing to remember is that Strings in .NET are immutable--that is, they don't change. So, there is no point in differentiating between references to two identical strings.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|