|
Hi,
as long as i known this control i've always used it by incrementing Known Steps
like a For Loop :
<br />
for (int i = 0; i < length; i++)<br />
{<br />
progressBar1.Increment(1);<br />
}<br />
now i want him to do so but for Operations Loke : (Do func1, and Func2....)
and to update the progres not by steps but with Time...
What i mean is to BIND the ProgressBar to an operation
Can anybody show my the way....
THANKS
Have Fun
Never forget it
|
|
|
|
|
You have to hand craft that binding. The simplest way is updating the progress bar status inside the operations themselves.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
|
half-life wrote: i thougt about it, but it's not that simple
(how said life is simple?, )
Oh, I know, of course: my sign is all about.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
i working on 2 parts application
windows service
and windows application
i want to attach them to the same configuration file.
is it possible.
and if it yes how shuold i do it ?
and if it is not?
what other solution.
regards
|
|
|
|
|
|
Hello Friends,
I am developing an application using C#.NET and SQL Server 2000 in this application i am getting date from server that is in (MM/DD/YYYY) format and match with system date but in system the date is in (DD-MM-YYYY) format whenever i match the date it shows an error message.
So can you give me the solution to set compatability between these two dates
|
|
|
|
|
Choose one step
1. Before comparing convert the system date to sql date formate.
2. Or before comparing convert the date formate in to system formate after comparing convert it aging to you working environment desire formate.
|
|
|
|
|
If you're using DateTime objects, surely they should compare correctly?
If you're using strings, how difficult is it to convert an MMDDYYYY string to DDMMYYYY or vice versa?
Cheers,
Vikram.
"If a trend is truly global, then that trend ought to be visible across ANY subset of that data" - fat_boy
|
|
|
|
|
... and use ISO 8601-compliant date formats (YYYY-MM-DD).
|
|
|
|
|
Hi guys
I am working on a project in which i need to add a pic an save it in any instance e,g dll etc. How can i create dll in running of an application and add something to it.
any link or hint will be appreciate.
|
|
|
|
|
|
I have a dataset with multiple tables in it. This dataset is created by reading an XML which has nested tables which is shown below.
<allocate>
<cabin cabintypeId="3" cabinType="deluxe" shareFlag="true" OccupancyType="TripleShare"
sameGender="true" cabinId="001" Adult="2" Child="0" Infant="0" availablebeds="1">
<occupant firstname="Micheal" lastname="Lauzon" age="adult" gender="male" nationality="UnitedStates"
usePackage="yes" roomrate="100" presold="true" />
<occupant firstname="John" lastname="Martin" age="adult" gender="male" nationality="Australia"
usePackage="yes" roomrate="100" presold="false" />
</cabin>
<cabin cabintypeId="1" cabinType="Standard" shareFlag="true" OccupancyType="single" sameGender="true"
cabinId="005" Adult="1" Child="0" Infant="0" availablebeds="0">
<occupant firstname="Jacob" lastname="Dror" age="adult" gender="male" nationality="UnitedStates"
usePackage="yes" roomrate="90" presold="false" />
</cabin>
</allocate>
once it is transferred to a dataset, it is divided into two independent tables "Cabin" and "occupant". With what reference can I read the data and identify it. What I mean is, in the above XML Set, how can I differentiate that for cabintypeId="3" there are two occupants named John and Michael. As well as for cabintypeId="1" occupant firstname="Jacob". As Cabin and Occupants are two different tables. I suppose I need to identify some Key value for the Relation defined internally for the datatables. How can I do this? Please help me out.. If I am not clear, I can Explain it more...
Thanks... Rijz
|
|
|
|
|
Hi,
In socket programming, I listen to the port using,
this.serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, System.Net.Sockets.ProtocolType.Tcp);
this.serverSocket.Bind(localEndPoint);
this.serverSocket.Listen(0);
this.serverSocket.BeginAccept(AsyncCallBackOnAcceptMethod, null);
When a client tries to connect to the port, I am able to connect to the client and send and receive messages.
The problem is, when the client disconnects by accident (ie... Killing the client application), I have to close the socket. How the server can be notified of the client disconnection? Is there any event for this in the socket class? or Do I need to ping the client frequently at regular intervals to check for connectivity?
Raja Pandian
|
|
|
|
|
Hi
There's no event for disconnecting in Socket or any other network class in .net (as far as i know...)
but there's an easy way to detect connection loss...
if i use sockets, i always use to write synchron and read asynchron.
that means, after connection you do a BeginRead on the socket (or network stream...).
in your callback - method you call EndRead with the IAsyncResult you receive. if EndRead returns 0 the connection is lost.
this gives you an immediate "Event" when the client disconnects correctly. if the Disconnect is accidently (like someone plugs out the network on the client, or the client crashes) you will get the event after the timeout (about 10-20 seconds i think...)
hope this helps
greets
m@u
|
|
|
|
|
I am working on creating a rich text box control to serve as a "visible" log of events. In order for it to work properly, it must be able to accept log entries from different threads.
I tried following the recommendations given by Microsoft on this page: http://msdn2.microsoft.com/en-ca/library/ms171728.aspx
The recommended method in the examples is to call a BackgroundWorker and perform the update in the BackgroudWorker's RunWorkerCompleted event.
In order to ensure that the text was available to the RunWorkerCompleted event, I added a DoWork event that, essentially, takes the text from it's EventArgs.Argument and puts it in the .Result area.
I have included a stripped down version of the code below. Executing this with only one call to AddEntry works wonderfully: AddEntry calls AddEntryInBackground.RunWorkerAsync, DoWork is executed, then RunWorkerCompleted and the desired text shows up in the textbox.
However, when there is a second call to AddEntry, it all falls apart. It seems as though the first call's DoWork execution is interrupted by the second call and never completes. The second call waits forever for IsBusy to be false.
I am unable to find anything that may explain why this occurring - Microsoft recommends this procedure as the "thread-safe" way to avoid simultaneous access to a form's control - which it does (in the same way that deliberately driving your car off a cliff keeps you from accidentally driving your car off a cliff). It appears that the BackgroundWorker only "works" for a very limited amount of time, after which control is passed back to the main thread and the BackgroundWorker remains in a permanent unfinished state.
Can anyone point me in the right direction?
Many thanks,
The main form
using System;
using System.ComponentModel;
using System.Threading;
using System.Windows.Forms;
namespace TestVisibleLog
{
public class VisibleLog : RichTextBox
{
private string timeStampFmt;
private int maximumBytes;
private string[] timeStampTokens;
private BackgroundWorker AddEntryInBackground;
public VisibleLog ( )
{
this.Enabled = false;
timeStampFmt = "";
maximumBytes = 512;
timeStampTokens = "dow,yoc,moy,dom,hh,mm,ss".Split(',');
this.Text = "";
AddEntryInBackground = new System.ComponentModel.BackgroundWorker();
AddEntryInBackground.DoWork += new System.ComponentModel.DoWorkEventHandler(AddEntryInBackground_DoWork);
AddEntryInBackground.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(AddEntryInBackground_RunWorkerCompleted);
}
public string TimeStampFormat
{
set
{
timeStampFmt = value;
if ( value != "" )
{
timeStampFmt += ": ";
for ( int index = 0; index < timeStampTokens.Length; index++ )
timeStampFmt = timeStampFmt.Replace(timeStampTokens[index], "{" + index.ToString() + "}");
}
}
}
public int MaxBytes
{
set
{
maximumBytes = value;
}
}
public void AddEntry ( string EntryText )
{
while ( AddEntryInBackground.IsBusy )
Thread.Sleep(100);
AddEntryInBackground.RunWorkerAsync(EntryText);
}
private void AddEntryInBackground_DoWork ( object sender, DoWorkEventArgs e )
{
string entryFormat = timeStampFmt + "{" + (timeStampTokens.Length).ToString() + "}.";
string logEntry = string.Format(entryFormat,
DateTime.Now.DayOfWeek.ToString().Substring(0, 3),
(DateTime.Now.Year % 100).ToString("D2"),
DateTime.Now.Month.ToString("D2"),
DateTime.Now.Day.ToString("D2"),
DateTime.Now.Hour.ToString("D2"),
DateTime.Now.Minute.ToString("D2"),
DateTime.Now.Second.ToString("D2"),
e.Argument);
e.Result = logEntry;
}
private void AddEntryInBackground_RunWorkerCompleted ( object sender, RunWorkerCompletedEventArgs e )
{
int overage = this.Text.Length + ((string)(e.Result)).Length + 1 - maximumBytes;
if ( overage > 0 )
{
int cutoff = this.Text.IndexOf("\n", overage);
if ( cutoff == -1 )
this.Text = (string)e.Result;
else
this.Text = this.Text.Substring(cutoff + 1) + "\n" + (string)e.Result;
}
else
this.Text += ((this.Text.Length > 0) ? "\n" : "") + (string)e.Result;
}
}
}
The new control
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace TestVisibleLog
{
public class Form1 : Form
{
public Form1 ( )
{
InitializeComponent();
this.statusLogBox.TimeStampFormat = "yoc/moy/dom-hh:mm:ss - ";
this.statusLogBox.AddEntry("This is entry 1");
System.Threading.Thread.Sleep(60000);
this.statusLogBox.AddEntry("And here is another entry");
}
private System.ComponentModel.IContainer components = null;
private VisibleLog statusLogBox;
protected override void Dispose ( bool disposing )
{
if ( disposing && (components != null) )
{
components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent ( )
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Text = "Form1";
statusLogBox = new VisibleLog();
this.SuspendLayout();
this.statusLogBox.Location = new System.Drawing.Point(13, 13);
this.statusLogBox.Name = "statusLogBox";
this.statusLogBox.ReadOnly = true;
this.statusLogBox.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Both;
this.statusLogBox.Size = new System.Drawing.Size(256, 241);
this.statusLogBox.TabIndex = 0;
this.statusLogBox.Text = "";
this.statusLogBox.Anchor = AnchorStyles.Bottom | AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
this.statusLogBox.Enabled = true;
this.Controls.Add(statusLogBox);
this.ResumeLayout();
}
}
static class Program
{
[STAThread]
static void Main ( )
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
Clive Pottinger
Victoria, BC
|
|
|
|
|
That is not the way BackgroundWorkers are meant to be used. They are typically created to do some background work, report progress (if any) on the UI thread, and then indicate completion of the background work on the UI thread.
If all you need to do is update text from a non-UI thread, you are much better off using Control.Invoke[^] or Control.BeginInvoke[^].
Your code would then look like
delegate void StringInvoker(string t);
void AddEntry(string text)
{
if (this.InvokeRequired)
{
this.Invoke(new StringInvoker(AddEntry), text);
return;
}
this.Text = ...;
}
}
|
|
|
|
|
Thank you Senthil.
When I read the page on the MSDN site, the Invoke seemed to make the most sense. However, I ran into a problem which I thought might have been caused by using Invoke. Since Microsoft says
"The preferred way to implement multithreading in your application is to use the BackgroundWorker component" I thought I would set the code up that way.
Now I believe my initial problem was not related to my use of Invoke. I will put the code back and track down my problem.
Thanks again. I will figure out C#, and by the year 2034 I'll be qualified to write thread-safe, XAML-based, SQL powered Hello World programs on any XP systems that may still be around
Clive Pottinger
Victoria, BC
|
|
|
|
|
Thanks again, Senthil.
I was wondering... do you have any idea why my use of BackgroundWorker failed? I thought I set it up correctly. Now that I have been exposed to it, I think I see were it could be useful in the future and I'd like to know that I can use it without getting locked up.
Clive Pottinger
Victoria, BC
|
|
|
|
|
BackgroundWorker is meant to be used for running long running operations in the background - essentially operations for which you would create a Thread yourself. The difference is that you can use the BackgroundWorker to report progress and completion without having to manually use Invoke or BeginInvoke. Bulk file copy and application initialization (with a splash screen indicating progress) are two places where a BackgroundWorker would work well.
The reason I suggested that you use Invoke/BeginInvoke was that you were not running any big operations in DoWork, you were simply using it to marshal the call to the UI thread by setting the Result property. That is exactly what Invoke/BeginInvoke is supposed to do. What's more, the BackgroundWorker's DoWork will run on a threadpool thread - this is in addition to the other thread on which you're doing the actual work. Invoke/BeginInvoke will not use a threadpool thread, it simply causes the delegate to execute on the UI thread.
|
|
|
|
|
Hi All,
Is it possible to flush the code output by JIT?. I want to force the CLR to recompile on the fly.
This problem I am investigating is similar to self modifying code.
Jeff
|
|
|
|
|
|
I googled. Got nothing. I have a class called Square which extends PictureBox. Now I have a class called Tank which extends Square:
public class Square : PictureBox
{
public Square (int type, int row, int col){}
}
public class Tank : Square
{
public Tank (Bitmap[] images, int type, int row, int col){}
}
I tried super like Java uses but it doesn't exist so how do I call Square's constructor from Tank's constructor?
|
|
|
|
|
public Tank (Bitmap[] images, int type, int row, int col) : base(type, row, col) {
}
Experience is the sum of all the mistakes you have done.
|
|
|
|
|