|
Hi,
Programm3r wrote: I want to create two threads and declare an enumeration to store some thread states (not referring to ThreadState). I.E:
No this is not a good approach, as it is not promoting code reuse.
Programm3r wrote: When the one thread wants to do some processing, it first check the state of the other thread before proceeding. Should the state be in threadSleeping state the one thread puts the other one in a Suspend state and can continue processing, thus the following can be prevented:
A thread may be performing a system-wide-synchronized operation like locking a range of bytes in a file, writing to those bytes, unlocking those bytes, then closing the file. A thread is suspended before the unlock, that range of bytes will remain locked for an indeterminate amount of time until the thread is resumed or the process terminates
If I've read correctly your process is fine. The usual approach when dealing with two threads that are sharing one resource is to use a mutex semaphore to block one thread while the other is doing some work.
I believe that .NET has classes (Mutex, Semaphore) in System.Threading that support this.
I hope this helps,
Cheers,
|
|
|
|
|
I Wount To Serialise All Controls In Windows Application
I Put This Code To Serialise the Button
/**************************************************/
/**************************************************/
private void serialize( )
{
Stream stream = File.Open("Thaer.xml",FileMode.Create);
SoapFormatter formatter = new SoapFormatter();
object obj = this.button1;
formatter.AssemblyFormat=System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Full;
try
{
formatter.Serialize(stream, obj);
}
catch { }
}
/*****************************************************/
/*****************************************************/
But This Code In .Net Give Me This Exeption :-
Type 'System.Windows.Forms.Button' in Assembly 'System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.
I Wount To Serialise The Button As Object And The TextBox
The Serialisation of it Must Have The Status Of It As Visible Or Hiden And The Size And Colore And and so on But Without Declare The Variable For It ,I wount to Serialise the Button With His Proper........
Who I Can Do It ?
Thaer
|
|
|
|
|
If you want to serialize a class, you must set put an attribute, for example:
[Serializable]
public class MyClass
{
}
I think you cannot serialize a button.
|
|
|
|
|
thanks Mr stancrm .
But Are You Sure I Can't Serialise the Controle .
My Manager is pressing To Serialise the control in Windows Application Or Web Application , From Last Day I Research on the EnterNet To Serialisation The Controls in Form by Using the C#.Net , I Don't Know What I Can Do .
Thaer
|
|
|
|
|
thanks Mr stancrm .
But Are You Sure I Can't Serialise the Controles .
My Manager is pressing To Serialise the control in Windows Application Or Web Application , From Last Day I Research on the EnterNet To Serialisation The Controls in Form by Using the C#.Net , I Don't Know What I Can Do .
Thaer
|
|
|
|
|
You cant serialize controls and many other classes. You need to find specific data you want to save/restore, and serialize that.
|
|
|
|
|
Hi,
kindly help me that, how to read null values from datagridview?
Thanks in advance
(Riaz)
|
|
|
|
|
You read it like any other value. E.g.
object cellValue = dataGridView.Rows[0].Cells[0];
Doesn't matter whether it's null or not. Does this answer your question?
|
|
|
|
|
i am facing an error "NullReferenceExeption was unhandled" using following codes.
object oValueChecker = Convert.IsDBNull(dataGridView1[5, e.RowIndex].Value)? "0" :
dataGridView1[5, e.RowIndex].Value.ToString().Trim();
if (oValueChecker == "0")
{
dataGridView1[5, e.RowIndex].Value = "0";
}
|
|
|
|
|
Hi.
Have you tried
if (string.IsNullOrEmpty(dataGridView1[5, e.RowIndex].Value.ToString()))
{
dataGridView1[5, e.RowIndex].Value = "0";
} I think it should work.
Kjetil
|
|
|
|
|
Kjetil Svendsen wrote: string.IsNullOrEmpty(dataGridView1[5, e.RowIndex].Value.ToString())
IF the Value property is null, you will still get a NullReferenceException .
|
|
|
|
|
M Riaz Bashir wrote: Value.ToString()
If Value is null , ToString() will FAIL!
|
|
|
|
|
How to get default printer name while calling the windows service using c#?
vinu
|
|
|
|
|
|
I am going to Migrate my project from Foxpro to dot Net Platform. My Project has lot of codings in the background database functions. Could you please suggest me which is the better option.Vb.net or C#.net ?
|
|
|
|
|
i think c# would be better option.
rahul
|
|
|
|
|
You ask this in the C# forum and expect an unbiased answer?
C# is a more terse syntax than VB's more verbose syntax. But both languages are equally powerful, so choose what you're comfortable with.
|
|
|
|
|
No language in the framework is stronger or weaker than other languages. Its just a matter of your comfort.
|
|
|
|
|
Not really accurate. For example you can use pointers in C# (in unsafe mode), while in VB.NET you can't.
|
|
|
|
|
In terms of technical power, the languages are identical. Both are compiled to IL, so have exactly the same functionality available.
In terms of syntax. C# adopts a more C style syntax (with curly brackets and stuff) whereas vb.net adopts a syntax that is more verbose, it is very similar to the original visual basic languages, which is obviously derived originally from basic. This is mealy a matter of preference to be honest.
Finally, there is the culture. The communities of VB.net developers and C# developers are different, and different people fit best in different communities. This is mainly because of the origins of the languages, vb.net developers are largely those who have moved forward from VB6, whereas C# developers are largely those who have moved forward from either C++ or Java.
This wikipedia page compares some of the differences in the languages. Note that most of these are mealy syntactical and easily overcome:
http://en.wikipedia.org/wiki/Comparison_of_C_sharp_and_Visual_Basic_.NET[^]
This article takes an in depth look at the two communities:
http://www.codeproject.com/KB/dotnet/CSharpVersusVB.aspx[^]
Simon
|
|
|
|
|
how do i get the first column value base on the selected row
this.dataGridView1.CurrentCell.Value.ToString();
this gives me the value of the column and the selected row cell..
example i click any column of the row i only want to retrieve the first column value which is the ID
|
|
|
|
|
dataGridView.CurrentRow.Cells[0].Value will give you the value of the current row's first cell. Is that what you're looking for?
|
|
|
|
|
|
Hi,
This should work:
this.dataGridView.Rows[this.dataGridView.CurrentCellAddress.Y].Cells["dataGridViewTextBoxColumn0"].Value.ToString());
where dataGridViewTextBoxColumn0 is the column name desired.
For Sure
Mosd
|
|
|
|
|
I have one web application(1.1 version.),Asp.net with C#,and i want to insert data to the form.how to insert the data to the form,and i want to show all the records in Data grid.
|
|
|
|