|
Hello all i am noob to C#(though i have a lot of former experience with c/c++)
anyway i am new to graphical oriented aplications)
I created a form .
the doublebuffering field is set to true.
Now i am animating a square on the screen using the timer controler
and the system.drawing.graphics functions.
I still see flickering effects though i turned on the doublebuffering, i know that the doublebuffering option should eliminate the flickering things but it doesnt.
anyone got any idea why it happen?
I am using VS2005
|
|
|
|
|
We'd really have to see some code. Also, if you're doing the painting for the control itself, make a call to the following inside you're constructor:
this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
|
|
|
|
|
|
Hello,
I have a BackgroundWorker object which I use to call a webservice. I want the call to be able to be cancelled, but unfortunately calling CancelWorkerAsync only sets a property and the DoWork event handler must return. However, since I am blocked in the webservice call, I can't check for the property or cancel. Is there a way to kill the worker process from the UI thread?
Thanks in advance,
Luis Alonso Ramos
Intelectix
Chihuahua, Mexico Not much here: My CP Blog!
|
|
|
|
|
Hi
Why don't you use the async methods to call the web service in your thread. Then you can then put your thread in a loop ( with a Sleep call ) which polls for your two exit conditions - cancellation or result.
In fact, why do you need a BackgroundWorker ? Why not just call the async methods from your main thread?
----------------------------
Be excellent to each other
EasiReports[^] My free reporting component for WinForms.
|
|
|
|
|
Nicholas Butler wrote: Why not just call the async methods from your main thread?
Because actually I'm using remoting through the internet, not a web service. It's a call that searches for customers, so it might take more than a few seconds.
Luis Alonso Ramos
Intelectix
Chihuahua, Mexico Not much here: My CP Blog!
|
|
|
|
|
You can't cancel it because the BackgroundWorker uses a thread from the .NET thread pool, IIRC.
What I usually do, Luis, is have the background worker spawn yet another thread inside the DoWork event handler. That thread just sits there and monitors the thread for either completion or cancellation of the background worker. It looks something like this:
void worker_DoWork(object sender, DoWorkEventArgs e)
{
IAsyncResult result = myWebServiceMethodDelegate.BeginInvoke(...);
while(result.IsCompleted == false && this.backgroundWorker1.CancellationPending == false)
{
Thread.Sleep(...);
}
}
This way, if you cancel the background worker, your DoWork thread will return relatively quickly (as soon as it sees that CancellationPending is true).
Also, have a look at Roy Osherove's ExtendedBackgroundWorker[^], which addresses the problem you're running into.
|
|
|
|
|
I'm actually using remoting, so I don't have asynch methods to call. But creating another thread sounds like a good idea.
I'll take a detailed look at the page you suggest, it seems it will be of help!
Thanks!
Luis Alonso Ramos
Intelectix
Chihuahua, Mexico Not much here: My CP Blog!
|
|
|
|
|
Luis Alonso Ramos wrote: I'm actually using remoting, so I don't have asynch methods to call.
You can still do async calls using remoting. Just wrap your remote method in a delegate and call BeginInvoke on that delegate:
void MyRemoteMethod()
{
...
}
ThreadStart del = new ThreadStart(MyRemoteMethod);
del.BeginInvoke(...);
|
|
|
|
|
I'll take a look into that. Thanks, Judah!
Luis Alonso Ramos
Intelectix
Chihuahua, Mexico Not much here: My CP Blog!
|
|
|
|
|
Hopefully this will proove to be a classic school boy error, but I am damned if I can find the solution to this problem.
I have a project that has various class organised across various namespaces. If I use the following using statement:
using AndTheOther = Project.This.That.AndTheOther;
Everything work fine, i.e. I can call:
AndTheOther.MyRandomMethod();<br />
AndTheOther.MyRandomClass mrc = new MyRandomClass()<br />
However, if I use the following using statement:
using Project.This.That;
The compiler (VS 2003) fails with the usual
(144): The type or namespace name 'AndTheOther' could not be found (are you missing a using directive or an assembly reference?)
Can anybody tell me what I have got wrong?
|
|
|
|
|
It's Working As Designed. You can't partially resolve a namespace with a using statement, it's all or nothing.
|
|
|
|
|
OK I can live with that, thanks for the prompt reply.
Now just to test your skills further How about this pearl:
I have another namespace problem that I think may be related:
I have the following class:
<br />
namespace Where.No.Man.Has.Gone<br />
{<br />
class Before<br />
{<br />
.....<br />
}<br />
}<br />
In another area of the code I need to use the Before class, so I duly created a using statement for it and called the class:
<br />
using Where.No.Man.Has.Gone<br />
<br />
namespace Right.Here.Right<br />
{<br />
class Now<br />
{<br />
Before b = new Before()<br />
}<br />
}<br />
The compiler fails with this on the Before class initilialisation, but does work with this:
<br />
using Where.No.Man.Has.Gone<br />
<br />
namespace Right.Here.Right<br />
{<br />
class Now<br />
{<br />
Where.No.Man.Has.Gone.Before b = new Where.No.Man.Has.Gone.Before()<br />
}<br />
}<br />
The using statement is valid, as the compiler does raise an eyebrow at it.
|
|
|
|
|
Do you have another class named Before in either the current namespace of one of the other namespaces that you are using?
|
|
|
|
|
i want to learn how to create pop-up alert forms like the new-message alert in outlook 2003, the download-complete pop-up alert in firefox, and the pop-up alerts in instant messaging programs.
anybody know where i can find a good tutorial on this for beginners?
-- modified at 13:43 Monday 10th April, 2006
|
|
|
|
|
They're usually just modeless dialogs moved from outside the screen to (screen - left | screen - height)
Take a look here
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
|
|
thanks guys
|
|
|
|
|
How to set monitor application activity?
Need to have a list of all started applications!
If it is possible, please tell me... Or say in what way I must see!?
-- modified at 15:17 Monday 10th April, 2006
|
|
|
|
|
Sergey Gorchichko wrote: Need to have a list of all started applications!
System.Diagnostics.Process.GetProcesses
This question has been answered many, many times on this forum. Next time use the forum's search functionality before asking.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: How 'bout a little guitar now?
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
I know this namespace! But I can't understand the best algorithm to update the list of processes!!!
|
|
|
|
|
This is an issue in the sense that it's irritating me, but i'm sure it was designed as a feature. When using a DataGrid bound to a DataSet with sorting enabled, the scroll bar will tend to jump around . Here's what I'm trying to do. I have a DataGrid that will be displaying anywhere from 150 - 500 individual rows. These rows are constantly added/deleted/updated on a one second loop. The issue is when the user has scrolled down the list and clicked on an item. If they try to sroll back up then when the DataGrid updates with new rows, it will jump back to the last selected row. I've tried overriding the GridVScolled message and stored the origal position and then reapplying the position after sort. This works but if the row data changes then the scroll bar will jump to follow where it went. What I'm trying to get is a dumb scrollbar. I want the scrollbar to stay at Vertical position 16 if that's where the user put it no matter what the sort or active cell is. Any idea's where I should be headed on this. Thanks for the help.
Pseudo Quasi Coder
|
|
|
|
|
Can someane explain me how can i use a custom font that was added to my system in a windows forms application for .NET framework 2.0?
The font is available in my system but it isn't available in Visual Studio. Is it that i can only use fonts already contained in a assembly pre-packaged with the .net framework?
I wasn't able to find any information about fonts and windows forms on the web.
Help please!
|
|
|
|
|