|
Something like this should work:
...
ApplicationDeployment ad;
UpdateCheckInfo info;
if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
{
ad = ApplicationDeployment.CurrentDeployment;
info = ad.CheckForDetailedUpdate();
if (!info.UpdateAvailable)
{
MessageBox.Show("No Update Available", "Update Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
bool doUpdate = true;
if (info.IsUpdateRequired)
MessageBox.Show("There is a required update available. Downloading now","Software Update", MessageBoxButtons.OK, MessageBoxIcon.Information);
else
if (MessageBox.Show("A new Softwrae Update is Available. Download now?", "Software Updates", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
doUpdate = false;
if (doUpdate)
{
ad.Update();
MessageBox.Show("The Updates have been downloaded. Restaring application", "Upgrade Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
Application.Restart();
}
}
...
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
Hi all,
I would like to know whether the following would be wise or not:
Seeing that 'System.Threading.Thread.Suspend()' is obsolete, I want to create two threads and declare an enumeration to store some thread states (not referring to ThreadState). I.E:
public struct THREAD_STATUS
{
public int threadWorking;
public int threadSleeping;
}
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
Will this be a good approach?
Many thanks in advance
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
Programm3r wrote: I want to create two threads and declare an enumeration to store some thread states (not referring to ThreadState). I.E:
why retype something thats already been written for you?
|
|
|
|
|
Well thank you for pointing that out. Now to get back to my question; is it a good approach?
Many thanks again...
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
You could also try using the Monitor class (really nifty).
eg.
<br />
ArrayList TempAl = new ArrayList();<br />
<br />
Monitor.Enter(TempAl);<br />
TmpAL.Add("test text");<br />
Monitor.Exit(TempAL);
Althought if you were using an array list, its better to load the values into a temporary array (or array list), then process it, then re-enter the Monitor at a later stage, and append the changes (depending on how much processing you had to do).
|
|
|
|
|
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
|
|
|
|