|
Yup!! It was stupid alright. I had to paste my code in here before I even noticed it....I configured UnicodeEncoding when I obviously need my encoding to be ASCIIEncoding()
I'll leave this here so google searches might find it - remember that you need ASCIIEncoding if you're trying to upload an xml file lol
"I need build Skynet. Plz send code"
|
|
|
|
|
I am trying to figure out how I can properly support multiple (& identical) events using a single delegate/handler. What I am experiencing is that I can easily tied my events to a single handler (i.e., using += ), but when any one of the events fire each instance of the handler method executes. I did not expect this behaviour as I had assumed that each delegate creation was instantiating a specific copy of itself and would be internally resolved. I have a full project space that shows this behaviour. Here is some code from the main program that shows the overall structure that I currently have:
namespace EventsDelegateIssue
{
public partial class MainForm : Form
{
#region - Variables -
DoSomeWork[] oDoSomeWork;
delegate void SetMessageCallback(string Message);
#endregion
#region - Constructor/Destructor -
public MainForm()
{
InitializeComponent();
//Create some worker objects and connect their events to handlers
oDoSomeWork = new DoSomeWork[3];
for (int i = 0; i < oDoSomeWork.Length; i++)
{
oDoSomeWork[i] = new DoSomeWork();
oDoSomeWork[i].Index = i;
oDoSomeWork[i].OnMessage += new PostMessageEvent.OnMessageEvent(MainForm_OnMessage);
onMessage_event += new onMessage_delegate(onMessage_method);
oDoSomeWork[i].OnData += new RaiseDataEvent.OnRaiseDataEvent(MainForm_OnData);
onData_event += new onData_delegate(onData_method);
}
}
#endregion
#region - Form Control Event Handler(s) -
private void btnDoSomeWork_Click(object sender, EventArgs e)
{
//Let's start our worker objects such that [0] finishes first, [2] second, and [1] third
oDoSomeWork[0].Count(10);
oDoSomeWork[1].Count(50);
oDoSomeWork[2].Count(20);
}
#endregion
#region - DoSomeWork Event Handlers -
//These worker event handlers check to make sure that they can handle the task on the proper thread
//Handle worker generated messages
public delegate void onMessage_delegate(PostMessageEvent messageHandler);
private event onMessage_delegate onMessage_event;
private void MainForm_OnMessage(PostMessageEvent messageHandler)
{
if (this.InvokeRequired == true)
{ BeginInvoke(onMessage_event, new object[] { messageHandler }); }
else
{ onMessage_method(messageHandler); }
}
private void onMessage_method(PostMessageEvent messageHandler)
{ UpdateMessage(messageHandler.strMessage); }
//Handle worker generated data
public delegate void onData_delegate(RaiseDataEvent dataEvent);
private event onData_delegate onData_event;
private void MainForm_OnData(RaiseDataEvent dataEvent)
{
if (this.InvokeRequired == true)
{ BeginInvoke(onData_event, new object[] { dataEvent }); }
else
{ onData_method(dataEvent); }
}
private void onData_method(RaiseDataEvent dataEvent)
{
UpdateMessage(dataEvent.Tag.ToString() + "; " + dataEvent.Data);
}
#endregion
#region - Update Message Function -
private void UpdateMessage(string Message)
{
//This message handler also checks to see if it is operating on the correct thread so as to
//not throw an exception
if (this.txtMessages.InvokeRequired)
{
SetMessageCallback d = new SetMessageCallback(UpdateMessage);
this.Invoke(d, new object[] { Message });
}
else
{ txtMessages.AppendText(DateTime.Now.ToString("HH:mm:ss") + "=> " + Message + "\r\n"); }
}
#endregion
}
}
|
|
|
|
|
Delegate derives from MultiCastDelegate[^] so this is expected behavior.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Ok, do you have any advice on how to tie multiple & identical events to a single delegate method such that on any one event firing the delegate method can be made to execute only once?
|
|
|
|
|
|
if you allow I want to know what that means intruction;
Persone pers1;
knowing that Persone is a class
thank you
|
|
|
|
|
membre123 wrote: what that means intruction;
Persone pers1;
It simply instructs the compiler to reserve enough space to hold a reference to an instance of the class (Persone in this case) which can then be referred to by the name pers1.
That's about it. It does nothing else.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
|
|
Hello,
somebody can help me to find a source code that runs for authentication by usb key.
please is very urgent, thank you in advance.
Regards
|
|
|
|
|
i think that there's another subject called "authentication token", but never works for me !!!
|
|
|
|
|
Hi taztazon,
yes i know, but it doesn't work, somebody help me
pleaaaase
|
|
|
|
|
Have you tried to google this? See This Link[^] below. There are a number of posts discussing this.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
hi kwagga,
I have not found soory.
another proposal?
|
|
|
|
|
Please stop reposting.
Maurinho0 wrote: is very urgent
Not to us it ain't.
|
|
|
|
|
|
Any particular kind of USB key? Are you talking about a specific device? A thumbdrive with a particular file on it? If it is really that urgent I would suggest you give more information so that people don't have to do a lot of work to try to help you.
|
|
|
|
|
Hi all,
I need to show a progress bar with % of loading while uploading a file.
Can any one help on this i am using VS2005.
Thanks in advance,
Balu.
|
|
|
|
|
If you're using your own code to do the actual upload, then you can write it to provide this information. If you're using a single method call and it does the upload for you, you've got no way on getting any progress information unless the class/method you use provides such.
|
|
|
|
|
You can derive the "remaining time" from the current percentage. You take a timestamp at the moment that processing starts. At every progress-change, you calculate the duration to do "1%", based on the time elapsed since the start. Subtract the progress from 100%, and multiply by the duration that you calculated in the previous step.
The first five seconds give a lousy avarage; it's generally a good idea to start it with the term "unknown/calculating".
I are Troll
|
|
|
|
|
Hello,
I am new in silverlight. I am using silverlight 3. I want to show "time left" on preogress bar in the hh/mm/ss format. How should I do this. PLease provide detailed solution.
|
|
|
|
|
archabhi123 wrote: I am new in silverlight.
I haven't used Silverlight yet, so it seems that you're already ahead of me
archabhi123 wrote: I want to show "time left" on preogress bar in the hh/mm/ss format.
To calculate how much time there's left, you'd first have to calculate how much time is required for a single step. Imagine your progressbar having 100 steps. First you'd write the code to time the first step.
Next, you multiply this with the amount of steps left. If your progressbar is at 60, you'd have 40 steps left to perform - and if a step takes two seconds, you can calculate that it will (probably!) take 40 (steps) * 2 (seconds) = 80 seconds.
Then you'd have to format those 80 seconds in the hh/mm/ss format and update the actual progressbar.
--edit;
You reacted to an somewhat older post on the forum. You might get more answers if you post it as a new question in the "Silverlight"-forum.
I are Troll
|
|
|
|
|
Hi guys,
I have windows se7ven,visual studio 2008 standart edition.
I try to cradle my emulator using this link:http://msdn.microsoft.com/en-us/library/aa188173%28v=VS.90%29.aspx[^]
When I try to choose the cradle option(step 3 in the link),I find it desactivated(can't work).
What is the problem??
when googling,I find that i can When I enable TCP/IP networking on the Device Emulator, the emulator can connect to the Internet and synchronize with Microsoft Exchange without cradling. The problem in this solution that the Virtual PC 2007 couldn't be installing having this error:
Error 1335. The cabinet file 'product.cab' required for this installation is
corrupt and cannot be used..."
Any suggestion will be very helpful for me
Regards
Marwen
|
|
|
|
|
Hi
Thanks I cradled my emulator.The Emulator must be running to be able to cradle it.
When should I uncradle my emulator???
When trying to install windows mobile device center,it failed.Should i connect a real device to be able to install this tool???
How can I get the IP number that is used for my device and PC for this TCP/IP connection??????
Thanks a lot for u clarification
Marwen
|
|
|
|
|
I want to understand this code pls
public GFile(string Filename)
{
string[] fileCtx = File.ReadAllLines(Filename, Encoding.Default);
GLine gline;
string[] tmpCtx;
foreach (string line in fileCtx)
{
if (line.Contains(m_leftBracket) && line.Contains(m_rightBracket) && line != m_CRCHeader)
m_Header = line;
else if (line != m_CRCHeader)
{
tmpCtx = line.Split(new string[] { m_Equals }, StringSplitOptions.RemoveEmptyEntries);
gline = new GLine(tmpCtx[0], tmpCtx[1]);
if (ContainsKey(gline.Code))
this[gline.Code].CRCGiven = short.Parse(tmpCtx[1]);
else
Add(gline.Code, gline);
}
}
}
|
|
|
|