|
I wonder why all the 1 votes - unless this the the nth time you have asked.
Seems your problem is to identify the sentence terminators within a string . or ? This should define your sentence and doing calcs on the word is easy.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks for your reply. Yeah, this is the first time I asked.
My problem is: in my database, I have defined words table selected from english dictionary and a number of product reviews which contains more than one sentence to check how many words can match with each product reviews. It is something like information extraction, but cannot use data mining.
Is that suitable if I use RegularExpression Libraries? I am not asking codes detail, but some references or some tips on the C# String functions. Thanks.
|
|
|
|
|
hey
i have to make a program in which a server send a video stream to client and client fill this stream into a buffer...now problem is i have to play this video stream from circular buffer filled by server...
Please HELP!!!!
|
|
|
|
|
Hi,
this is my last chance to understand how to update a database through a dataset.
My application is here : [1].
I did a simple application to understand the databases and relative classes in C#.
I have seen that VS2008 is not setting the updatecommand in the wizard, so I fill in by hand. Maybe the problem is there.
UPDATE Customers
SET LastName = @LastName, FirstName = @FirstName
WHERE (CustomerID = @CustomerID)
Thanks in advance.
Stefano
[1] http://www.mediafire.com/?3zgfdmzgnyg
|
|
|
|
|
Hello,
C# 2005
I am using a background worker to process some login information. However, the background worker has to stop and wait for 2 events to happen. Once these have finished the background worker can complete its job. They are callbacks that will call the Set() method of the AutoResetEvent.
So I am using AutoResetEvent to set when these 2 events have finished. However, I seemed to be getting this error message
"Exception has been thrown by the target of an invocation."
And Inner exception
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index".
The exception usually fires when the registration success leaves scope.
Many thanks for any advice,
AutoResetEvent[] loginWaitEvents = new AutoResetEvent[]
{
new AutoResetEvent(false),
new AutoResetEvent(false)
};
private void bgwProcessLogin_DoWork(object sender, DoWorkEventArgs e)
{
Console.WriteLine("Wait until event is set or timeout");
loginWaitEvents[0].WaitOne(3000, true);
if (this.accountInUseFlag)
{
if (this.lblRegistering.InvokeRequired)
{
this.lblRegistering.Invoke(new UpdateRegisterLabelDelegate(this.UpdateRegisterLabel), "Account in use");
}
else
{
this.lblRegistering.Text = "Account in use";
}
e.Cancel = true;
this.accountInUseFlag = false;
return;
}
else
{
this.bgwProcessLogin.ReportProgress(7, "Account accepted");
}
Console.WriteLine("Just Wait the result of successfull login or not");
loginWaitEvents[1].WaitOne();
if (this.registerSuccess)
{
this.bgwProcessLogin.ReportProgress(7, "Register Succesfull");
this.registerSuccess = false;
}
else
{
if (this.lblRegistering.InvokeRequired)
{
this.lblRegistering.Invoke(new UpdateRegisterLabelDelegate(this.UpdateRegisterLabel), "Failed to register");
}
else
{
this.lblRegistering.Text = "Failed to register";
}
e.Cancel = true;
return;
}
}
private void VaxSIPUserAgentOCX_OnSuccessToRegister(object sender, EventArgs e)
{
Console.WriteLine("OnSuccessToRegister() [ Registered successfully ]");
this.registerSuccess = true;
this.loginWaitEvents[1].Set();
}
private void VaxSIPUserAgentOCX_OnIncomingDiagnostic(object sender, AxVAXSIPUSERAGENTOCXLib._DVaxSIPUserAgentOCXEvents_OnIncomingDiagnosticEvent e)
{
string messageSip = e.msgSIP;
string sipErrorCode = "600 User Found";
if (messageSip.Contains(sipErrorCode))
{
this.accountInUseFlag = true;
Console.WriteLine("OnIncomingDiagnostic() WaitEvent.Set() accountInUseFlag: " + this.accountInUseFlag);
loginWaitEvents[0].Set();
}
}
modified on Saturday, May 16, 2009 10:18 PM
|
|
|
|
|
From the exception text, the exception seems to be occurring in UpdateRegisterLabel . Try debugging that method by placing a breakpoint at the start of the method.
|
|
|
|
|
Hello,
I solved my problem. It was something in the RunWorkercompleted.
However, there is one more thing. The registerSuccess and AccountInUse are global because they are been accessed from 2 different threads. Would it be better to put a lock on them?
Many thanks
|
|
|
|
|
Getting a setting a bool is an atomic operation. However, in your code there are gaps between checking the variables for true and setting them to false. It is possible to fall through on true and the variable then gets set to true again, whereupon you set it to false. This may not matter, but is a matter of concern.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Hello,
When you say that setting a bool is a atomic operation. Does that mean the the operation will has to complete all of it, or fail? What would be the difference in setting either a string or a integer?
Thanks,
|
|
|
|
|
steve_rm wrote: Does that mean the the operation will has to complete all of it, or fail?
Yes, the CLR guarantees that all operations on datatypes less than or equal to the size of a native pointer will be atomic. So on a 32 bit machine, storing and retrieving integers is atomic, while the same operations on longs (64 bits in size) are not.
|
|
|
|
|
"atomic" means the value will get set at once - other threads reading the value at the same time will either see the old value or the new value, nothing "in between".
Reading/writings strings and ints is also atomic.
However, reading/writing longs (or other value types >32 bit) is NOT atomic: you might end up reading 32 bits from the old value and the other 32 bits from the new value.
But even though it's atomic, I'd suggest that you still put a lock around it.
For example, in this code:
Initialization:
int a = 0, b = 0, c = 0;
Thread 1:
a = 1;
if (b == 0) c++;
Thread 2:
b = 1;
if (a == 0) c++;
From a simple look at the code, it seems that c will be 0 or 1.
c shouldn't be 2 because "c++" cannot run on both threads - it's incremented only if the other thread hasn't set its flag (a or b) yet.
Writes and reads to a,b are atomic. The increment of c is not atomic (read and write of c are atomic, but the combination read-increment-write isn't atomic).
But actually, it is possible for both "c++" to execute, so c could become 2! (though only on dual-core machines)
It's also possible that both "c++" execute but c still becomes only 1.
Both "c++" can execute because x86 CPUs are allowed to move the "read"-instruction from the if-condition above the write-instruction from the assignment above (or they might execute the read and write in parallel). I've tested this myself using hand-written assembler code, an Intel Core Duo WILL move reads above writes where possible!
You'll have to insert a memory barrier instruction to prevent the CPU from doing that.
In C#, the "volatile" keyword can be used for some kinds of memory barriers: volatile writes have release semantics, volatile reads have acquire semantics. That's sufficient for many cases of unsynchronized access to variables, but it doesn't help in the example I gave above - we need a full memory barrier there.
->
If you access shared variables without locks, might have to insert a memory barriers to synchronize the memory between CPUs. It's extremely hard to get those right.
So I would suggest that you keep it simple and always use a lock.
|
|
|
|
|
Without proper formatting this is too hard to read.
Use the PRE tags (not the code tags) to preserve formatting and indentation.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hello,
I have aspx web site. There are many files in this website (image files). How can i find a particular file (check if exist) in this site? there are also directories in the site with files inside- Is it possible to search the file recursively inside this directories too (without entering each one)?
|
|
|
|
|
Google Desktop search? Good answer or not?
|
|
|
|
|
No.
I want to put it in my application and file the file if it exist. The file is located in a website , not in the computer.
If there is no way to search for a file in website.
How can i check if a URL exists?
|
|
|
|
|
You can't unless u own the website but u can ping it or use HttpRequest
|
|
|
|
|
OK,
So how can i check if the website works? i mean if URL works...
|
|
|
|
|
Try to download a bit from it?
|
|
|
|
|
There is no a way to know a if a url is valid or not untill and unless you make a request to that url.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
OK thanks.
But how can i write this request? can you show me a code for it?
|
|
|
|
|
Google is always a good place to start. Have a look at This Website[^]
Seems to be exactly what you want to do.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
Ok thanks, It's good idea but it wont work for me (site problems- no matter).
I prefare to check if the URL is working or not? i mean to make a request to it... How can i do it?
|
|
|
|
|
Does anyone has an answer for me?
|
|
|
|
|
michaelgr1 wrote: How can i find a particular file (check if exist) in this site?
If you have a URL, issue a HTTP request and see whether you get a 404?
|
|
|
|
|
hello
Need clarification on why we have no C# virtual destructor - here's my understanding.
1. Unmanaged resources are freed by calling Dispose (true/false), managed resources are freed by call to Dispose(true).
2. Managed memory is freed by call to Dispose - Base class should mark Dispose virtual, Derived class should explicitly "override" base class Dispose and "Base.Dispose" should be called in Derived.Dispose (this way both Derived/Base Dispose are called in chain)
Question:
1. Should we make Base.Finalize (~Base really in C# syntax) virtual? Should we implement Derived.Finalize (~Derived in C# syntax)?
2. C++ destructor is C# destructor (or Finalizer) - now SINCE we really want to release resource (expensive ones in particular) in Dispose (deterministically, unlike ~Derived or ~Base), what really I'm asking is, why not "Virtual destructor" same style as C++: http://www.codersource.net/cpp_virtual_destructors.html[^]
In C++, if you declared destructor virtual, and "delete oDerived", BOTH destructor from Base and Derived are invoked (~Derived then ~Base). Why is this NOT the behavior in C#? That you need to call Base.Dispose explicitly in Derived.Dispose, relying on programmer to make sure both are called? Seems like C++ virtual destructor is cleaner?
Thanks
REF:
http://www.codersource.net/cpp_virtual_destructors.html[^]
http://msdn.microsoft.com/en-us/library/b1yfkh5e(VS.71).aspx[^]
dev
|
|
|
|