|
Hey Everybody!
I wrote a multi-threaded crawler (which is doing a more than just crawling).
This is the first multi-threaded program I'm writting so I'm having some problems with it.
I have a 2 groups of threads, one is downloading from the net, the other is extracting the URLs and other information.
I've synchronized the threads using semaphores.
The problem is that sometimes, after the program is running for a while, I'm getting an Exception with the message that the process is trying to perform an I/O (read or write) to an illegal spot in the memory (also it adds that it could be a memory corruption).
I've also experienced a few times that the program simply get terminated, without any warning or any notice (the visual studio simply returns to its original stat from the debug stat).
ANY Ideas how to fix that?!
I'm terribly stuck!
Thanks A LOT!!!!
|
|
|
|
|
Sounds like you are having data corruption, as a result of a lack of
thread synchronization: most data structures are not thread-safe, that is
if one thread is say modifying a List, and another thread suddenly kicks in,
and accesses the same List, it may find it in an inconsistent state.
The one remedy is adding all the required locks; without them, it seems to
work for a while; with them, if applied correctly, it will work forever.
I can't possibly reproduce all the theory here, you should look for either
the lock statement, or some specialized classes such as ReaderWriterLock Class.
|
|
|
|
|
hi there,
i m trying to convert textbox.text to int but it always giving error while runtime
"Input string was not in a correct format."
textbox.text = "00.0000"
nums =Convert.ToInt32(textbox.text);
i also try
nums =int.textbox.text);</
it give error same above
nums =(int)textbox.text;</
it gives error
Cannot convert type 'string' to 'int'
someone know anyother way???;)
Becoming Programmer...
|
|
|
|
|
try:
int nums = int.Parse(this.textbox.Text);
|
|
|
|
|
This will also throw an exception!
All the best,
Martin
|
|
|
|
|
i just want to remove the decimals thats why i m trying to convert it in int as int dont have decimals
i can remove decimals with other methods too but conversion is the best way i thought
Green Fuze wrote: try:
int nums = int.Parse(this.textbox.Text);
same error
Becoming Programmer...
|
|
|
|
|
What you want requires two steps. First, use double.TryParse ( or you will get an error ). Then, use Math.Floor, or Math.Ceiling, if you want to force rounding. Either way, case the double you end up with to an int.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello,
As your string represents a double value, you will get a system format exception.
This would work:
string text = "0";
int inums =Convert.ToInt32(text);
text = "00.0000";
double dnums =Convert.ToDouble(text);
But I recommend to use the TryParse methods.
They will not throw an exception.
double d;
if(double.TryParse(text,System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.CurrentCulture, out d))
{
}
else
{
}
All the best,
Martin
|
|
|
|
|
thanks but i dont want decimals remain
Becoming Programmer...
|
|
|
|
|
This will round it mathematical, but you also can use the Math functions or just modify the string.
string text = "1,5345";
double d;
if(double.TryParse(text,System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.CurrentCulture, out d))
{
int inums = Convert.ToInt32(d);
}
All the best,
Martin
|
|
|
|
|
ok i will
Becoming Programmer...
|
|
|
|
|
Data Entry Validation.
If decimals are illegal values prevent or validate their entry, don't leave your users guessing what the expected entry is.
Rhys
"The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it"
They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance."
Terry Pratchett
|
|
|
|
|
|
thanks but i think you replied it after 1 month xD
Becoming Programmer...
|
|
|
|
|
Hi!
I've one question:
I want to send a request to DNS server with type NAPTR. But I don't know how. Help me, plz!!!
|
|
|
|
|
Please explain me the use of keyword internal protected and internal with an example ??
what is the difference between internal protected and internal ??
Can construstor be declared internal protected/internal ?? why or why not???
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
google broken ?
internal means visible only within the current assembly. protected internal presumably means visible only to derived classes within the current assembly.
Yes, you can make a constructor whatever you like. If it's protected, obviously only derived classes can be created, unless a factory method is provided.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Sir actually , google too provides this much information.as far as any example is concerned that , upto this limit i can use the internal member vaiables, and till this limit , i can make use of internal protected.
I mean if u provide any small example , any example.Please
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
Is what you mean to ask, why would you use these things ?
Internal is useful for things you want to hide, but which should be visible within a module. For example, if you have a seperate data layer class that you want to be visible only to the entity classes within your module. internal protected allows you to create a base class which is derived from within your module, but which clients of your module are unable to extend.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: protected internal presumably means visible only to derived classes within the current assembly.
I knew I wasn't the only one.
protected internal means it's visible everywhere within the same assembly *and* to all subclasses.
Cheers,
Vıkram.
After all is said and done, much is said and little is done.
|
|
|
|
|
'internal' means any class in the same assembly can access it.
'protected' means any class that any inheriting class can access it.
'internal protected' (or 'protected internal' ) means that any class in the same assembly AND any inheriting class can access it.
example for internal : If application contains 2 files
Assembly1.cs, Assembly2.cs
If the first file contains a class (base class) (i.e. in assembly1)
The second file is in assembly2…. If u want to access the base class of assembly1 in assembly2 then u can’t access it…this is the concept of Internal…
In .Net 2.0 you can have 'friend' assemblies. If you make an assembly a 'friend' of another then it will have access to anything marked internal as if it was in the same assembly
pavan...
|
|
|
|
|
Assembly1 means Assemblyinfo.cs
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
You could have atleast rewritten what I gave rather than plagiarizing[^] my answer word for word
|
|
|
|
|
hello, I'm quite familiar in connection and manipulation of VB and MS Access. Actually I use ADODB connection and Im using the basic database manipulation functions like MoveNext, MoveLast, Update, AddNew and something like that. Could you please help me doing it in C#? I'm really still a noob in C# specially when it comes to database. could you please teach me how to connect, add, delete, insert, filter and other basic stuffs? I would be very thankful if you'll send me a sample program with explanation. Thanks in advance!
oyams
|
|
|
|
|
You're describing ADO. ADO.NET works completely differently. There are tons of tutorials on the web, just google 'access C#'.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|