|
but i mean, it will never run on a UI thread, so how do i update the progressbar? what will invoking p do? :\
|
|
|
|
|
The else code runs on the UI thread. When you call BeginInvoke or Invoke and pass it a delegate, .NET calls the delegate on the UI thread. In your example, you passed the same function as the delegate. When .NET calls the function on the UI thread, InvokeRequired will be false and the else code will run on the UI thread.
Have a look at What's up with BeginInvoke[^] to know more about this.
|
|
|
|
|
hi
i have sql server 2000 personal in server, and i want connect to it from client by vc#2005, but the following error shown me :
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
how to solve my problem ??
thanks
-- modified at 18:58 Friday 2nd March, 2007
|
|
|
|
|
|
I am working on a POS application that needs to run once, and then when called again it will just activate the current instance. So I have the run once code working but now I need to be able to pass params to the running instance. I am trying to implement a way to save the params to my properties.settings.default.param1, so when the exe is called the second time, I check for an existing instance by name, and if I find it I restore it. before I restore it I save the value of my params, and in the activated event of my form, I grab that data and present it to the user. Well this is not working all the time, sometimes it works sometimes it does not...I'm totally open to new ideas on this process...
Christopher J. Thornburg
Senior Systems Analyst
Ideal Card
|
|
|
|
|
Hi,
I dont know enough about settings files, I am not sure how it would behave when
more than one app instance exists, and how you could use them to communicate
(the first instance needs to reread once the second one changes the settings?).
Also I want solutions that would work on older .NET versions (1.1)
I have an app that wants to run as a singleton. My implementation works fine on
.NET 1.1 and 2.0
If it can create a named mutex, it knows it is the first instance, and it creates
a named pipe (sounds like the mutex is not really needed, could just try and create the
pipe right away I guess).
Otherwise, it connects to the pipe, sends the command line thru it, and exits.
The first instance has a separate thread that reads on the pipe, and acts on it
when something is received.
I use PInvoke to call CreateFile, WriteFile, ReadFile, CreateNamedPipe, ConnectNamedPipe
and CloseHandle.
|
|
|
|
|
Hello,
I have size problem! he hehe hehehe .. What I mean is that I wish to have the maximum working area available to me while I am developing. I realise that I can set the MainForm size but as the result the loaded window size is also going to be the same size.
Is there anyway that I can have the maximum working area during developing but once the application is built, if the maximum size is not chosen there are going to be horizantal and vertical scroller for accessing the entire application window.
I hope I managed to make sense out of my silly question. Once again, thank you very much guys for your help and I hope you have a great day.
Khoramdin
-- modified at 15:06 Friday 2nd March, 2007
|
|
|
|
|
I think you mean can you get the form to resize but keep the relative positions of various components. Have you looked at the Anchor property? Eg you can anchor a panel (for example) to stick to the right hand edge and resize with the form. You can also anchor most other visual components (buttons, text boxes etc...)
My apologies if this was not what you were intending.
|
|
|
|
|
Hi,
I have maintained html formatted text(help information) in XML file. like the following
eg.
<pre><Help>
<Page1>
<b>Login: </b> Press login button to login into the page
<page2>
<b>View: </b> Press View button to view the configuration details.
...
<Help></pre>
So iam taking the contents of Node Page1 using XML document to display the help for Page1 in Richtext box. But Richtext box not recognizing HTML tags. It simply display the contents.. How to present this content. Is it possible with RTB or is there any controls to display this HTML formatted text.
Thanks
Srini
-- modified at 14:46 Friday 2nd March, 2007
|
|
|
|
|
You can use the WebBrowser control to display html formatted text.
|
|
|
|
|
I can't use webbrowser..... since i am will only the text from XML. for displaying it in Webbrowser...we need to put into a separate HTML file.. and have to direct the webbrowser to that file path.... that is tedious job... and the webbrowser is not a stable component..
Any other solution here.
|
|
|
|
|
The RichTextBox control does not support HTML formatting. In order to display the formatted text, you need to convert the HTML to RTF, then set the RichTextBox.Rtf property to the converted text. The slick way to do it would be to create your own ICustomFormatter object that converts HTML markup to RTF, then pass it, along with your HTML string to StringBuilder.AppendFormat.
I don't know of any other way to tackle this problem. I'm sure there is a myriad of conversion tools out there and quite possibly an article or two on that topic on CP.
Sorry I don't have a better solution. Perhaps someone else does?
Ian
|
|
|
|
|
|
for example:
public class Foo<T>
{
T total=default(T);
void Add(T val)
{
total+=val;
}
}
which results in the compiler error:
"Operator '+=' cannot be applied to operands of type 'T' and 'T'"
Is there some way to tell the compiler that T is a value type? I don't see it in the possible constraints for T.
Marc
Thyme In The CountryInteracxPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
Use the where keyword:
public class Foo<T> : where T : struct {
T total = default(T);
void Add(T value) {
total += value;
}
}
---
single minded; short sighted; long gone;
|
|
|
|
|
Guffa wrote: Use the where keyword:
I tried "where T: struct" and I get the same error message.
Marc
Thyme In The CountryInteracxPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
You have to add contraints. Right now, the only thing the compiler knows about the type T is that its an object. I don't believe though you'll be able to do something like that because there's no interface for 'numeric' or something ;-D.
If you find something that works...please let me know. I've had to write something like this where I broke it out to a case by case basis.
|
|
|
|
|
Andrew Rissing wrote: If you find something that works...please let me know.
See Incincere Dave's post in this thread. A couple really cool articles on CP that address the problem.
Marc
Thyme In The CountryInteracxPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
|
Insincere Dave wrote: Here are two methods
Ah, I remember that article on using generics for calculations. In fact, I had voted a 5 for it!
Thank you so much for bringing those two links to my attention.
Marc
Thyme In The CountryInteracxPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
Hi All:
I am trying to work with the built in double buffering in C# Visual Studio 2005. I want to have no flicker. I have a timer event that throws an event every 100 ms when the timer event occurs it draws a square at the given location. This occurs very quickly. Behind the square is a four quadrant background. I am trying to do the double buffering so that the background is not redrawn everytime or so that it is smoother. When I set the doublebuffer function to true it flickers faster so I am obviously not doing something right. Please help!
Please view my Paint function:
<br />
public void XYZ_PaintData(object sender, PaintEventArgs e)<br />
{<br />
Graphics g = e.Graphics;<br />
Pen penRed = new Pen(Color.Red, 2);<br />
Pen penGreen = new Pen(Color.Green, 2);<br />
Pen penBlue = new Pen(Color.Blue, 2);<br />
Pen penWhite = new Pen(Color.White, 1);<br />
Pen penBack = new Pen(Color.Gray, 1);<br />
<br />
this.DoubleBuffered = true;<br />
<br />
<br />
<br />
penBack.DashStyle = DashStyle.Solid;<br />
<br />
g.DrawLine(penBack, 375, 105, 375, 600);<br />
g.DrawLine(penBack, 50, 325, 650, 325);<br />
g.DrawRectangle(penBack, x0XYZ, y0XYZ, x1XYZ, y1XYZ);<br />
AccelReadings = true;<br />
<br />
g.DrawRectangle(Pens.Black, xMXYZ, yMXYZ, 2, 2);<br />
<br />
<br />
}<br />
Laura
|
|
|
|
|
Well, I don't know what's causing the flickering, but I do see a HUGE resource leak in your code.
You MUST call .Dispose() on all of your Pen objects when you're done using them. If you don't, the unmanaged resources behind them don't get released and you'll eventually get an OutOfMemory exception and/or your system will start to do very weird things, even causing other applications to crash.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
I would set DoubleBuffered only once, probably in the constructor.
Maybe setting it every time causes the flickering you see.
And you either should make your pens class members (so they get created only once),
or Dispose of them every time you create them (wasting CPU cycles in creation, disposal
and garbage collection).
I am not sure what "AccelReadings=true" is supposed to do there. Seems not to belong
in a paint handler.
Final remark: the comment "Line that is drawn when timer event occurs" is inaccurate,
the line is drawn every time paint is executed (which could be on every time tick and
more), it probably gets instructed to move in the time tick handler.
Hope this helps.
|
|
|
|
|
Laura,
Another thing you can try is your own simple double buffering: Paint everything to a temporary bitmap and then paint the bitmap to the graphics passed by the event args, like so:
Bitmap temp = new Bitmap(e.ClipRectangle);
// do your painting
e.Graphics.DrawImageUnscaled(temp, e.ClipRectangle);
That may help.
Incidentally, are you using transparency of any kind? Transparency can cause flickering despite double buffering.
|
|
|
|
|
we are creating Online Exams Module.Just lke any other online exams on other real sites.
The Case is the user can attempt any question within 3 minutes.after 3 minutes,the next question automatically disappears and another question comes on the page.
We also want to show times in Minutes as a clock just like any other online exams.
My issue is that how can i show time on each page and how can i calculate every 3 minutes.
I know there is Timer/Thread class in c# for web application.But i dont know how they can efiicently work.
Or there is any other better method to do it.
Plaese help me with example or code.
---
My code is like this:-
System.Timers.Timer time1=new Timer();
time1.AutoReset=true;
time1.Interval=60000;
time1.Elapsed+=new ElapsedEventHandler(time1_Elapsed);
And..
private void time1_Elapsed(object source,System.Timers.ElapsedEventArgs e)
{
//call any function
}
but my WebForm seems running ambigously to me and not giving proper result.
Am i in right direction.
Please help me with suitable simple.
MY PLATFORM IS ASP.NET 2005
Posted via DotNetSlackers.com
|
|
|
|