|
|
|
code-frog wrote: ave seen that no net
Yeah, that's one thing I wish I could turn the clock back and have the CLR team change: the string.DoSomething functions don't actually modify the string as they would have you believe. They should've renamed them to make it more clear what's really happening. Better yet, make them static methods.
|
|
|
|
|
Nothing modifies strings, they are immutable.
|
|
|
|
|
Yeah I know, that's what I'm saying: the current string methods as they are lead one to believe they modify strings, when in reality they create copies of the original. The names should've been named something to reflect this fact (ReplaceInCopy or something), or have the string methods be static methods rather than instance methods.
|
|
|
|
|
Hi
I'm trying to build a quick app in C# to filter out some info from emails, like the user's email address and why the email didn't reach the user.
example :
The text I'm using is the following:
"Hi. This is the qmail-send program at store3.netvisao.pt.
I'm afraid I wasn't able to deliver your message to the following addresses.
This is a permanent error; I've given up. Sorry it didn't work out.
username@domain.com:
Sorry, no mailbox here by that name. (#5.1.1)"
I would like to build a regex based on this text.
Can anyone give me a hand on this?
Thanks in advance.
Jorge
-- modified at 19:18 Monday 10th April, 2006
|
|
|
|
|
What particular information are you looking to extract?
|
|
|
|
|
In this particular case I'm interested in extracting the email address and the specific reason why the message wasn't sent.
Example:
Hi. This is the qmail-send program at
I'm afraid I wasn't able to deliver your message to the following addresses.
This is a permanent error; I've given up. Sorry it didn't work out.
<username@domain.com>:
Sorry, no mailbox here by that name. (#5.1.1
Thanks in advance for the help.
Regards
Jorge
|
|
|
|
|
Hi,
I like to know is there any event that is fired before treelistview is displayed that sets the checked items. I know itemcheck event but like to know somethign like "Paint". I am using .NET 1.1 and C#.
Thanks in advance.
|
|
|
|
|
|
Thanks for the reply.
I tried the Invalidated event and its only fired for the first time. After the TreeListView is displayed once and then user clicks/checks one of its node, ItemCheck event is fired. I want to know the next event fired after ItemCheck that actually set the TreeListView with all the checked and expanded Items before dispayng.
Thanks.
|
|
|
|
|
Hello. I am using HttpWebRequest to post some photos to a website. For some reason, I can post two photos to the website, then every other one times out. So, I restart the program, it does the next two, then times out on the rest. I am using .net 2.0, and here is my sample code:
<br />
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(string.Format("{0}/{1}", this.sUploadURL, this.sAuthHash));<br />
req.Method = "PUT";<br />
req.AllowWriteStreamBuffering = true;<br />
req.KeepAlive = false;<br />
<br />
Stream reqStream = reqStream = req.GetRequestStream();<br />
FileStream reader = new FileStream(fullFileName, FileMode.Open);<br />
It times out when I call req.GetRequestStream() . Any ideas?
Mike - I love to program!
|
|
|
|
|
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.
|
|
|
|