My ID was hacked by someone. :((
shivamkalra
Posts
-
Worst joke ever.. -
Starting intrupped thread again..Hi, I need to design a program should be able to update certain textbox for each event inside the GUI and after every 10 seconds of most recent event, text tox should be back to original value..Let say
Event one occurs --> text box updated --> after 10 seconds --> text box back to normal
This is the case in perfect world, but it might be possible that someone create another GUI event during this period of 10 seconds..Event one occurs --> text box updated --> after 8 seconds --> event two occurs --> GUI updated --> after 2 seconds the other thread (10 seconds completed for first event), text box back to normal.
So in this case, for second event, the textbox get back to original value in just 2 seconds. I know I could use thread intrupt to cancel the other thread. But my question is, it the best way of doing it?? And what is there any other way to starting intrupped thread again, without making a new thread? Will thread intrupt make sure everything will go perfect?? Would you suggest some more efficient way? I may be misunderstanding about threading here, please forgive that. Any suggestions, links or comments will be appreciated. PS So far my code is like this..Thread t = new Thread(keep_run);
public void update()
{
t.Interrupt();
if (MessageLbl.InvokeRequired)
{
MessageLbl.Invoke(new setText(() => MessageLbl.Text = "User settings have been updated."));
}
else
{
MessageLbl.Text = "User settings have been updated.";
}t = new Thread(keep\_run); t.Start();
}
private void keep_run()
{
try
{
Thread.Sleep(10000);
MessageLbl.Invoke(new setText(() => MessageLbl.Text = "Welcome to MAT Downloader"));
}
catch { MessageBox.Show("Interrupted"); }
}
}If you find any other problems with the code then do mention them. Thanks Regards, Shivam Kalra :)
-
Task queues to execute a task one by one in file downloader program. [modified]Hello Everyone, I'm trying to automate file's downloading process from my server using winscp command line stfp downloader. It was required to process some standard output to detect errors and some events, so I redirected the standard output and standard input of process and set the shellexcute to false. Now I'm able to see the output messages on rich text box using asycn readline (BeginOutputhttp://msdn.microsoft.com/en-us/library/system.diagnostics.process.beginoutputreadline.aspx[^]) method provided in Process library. Now my problem, how can I write my program such that it is able to write commands to standard input asycn and at same time making sure that no command is missed, if previous command is under processing. Let say I've a text box and button..if I press a button then it writes the command on text box to standard input of the process and then it waits for the reply..and lets assume this whole task takes 2 seconds..but during this 2 seconds user can enter more commands which can not be ignored so must be added to some queue, which can executed later on. I'm not sure how should I achieve this? I'm sorry if I'm misunderstanding anything here..but I've no experience with mutli threading in C#..Please suggest some design pattern to do this..any help would be appreciated.. Thanks, Regards Shivam Kalra
modified on Friday, June 24, 2011 10:44 PM
-
I want to get removed as a co-authorYes it affecting my rep. Last month somebody hacked my account and cracked lot of poor jokes and my debtor points reduced to -345. DAM IT..but to be honest, I clicked on that link by mistake..
-
I want to get removed as a co-authorThanks you v. much. last time you helped me getting my password back. You are great! :)
-
I want to get removed as a co-authorHi, I became the co-writer of an article by mistake and article is not too good and it is reducing my overall point. How could I withdraw from it? I got the email invitation and I accepted it by mistake. My webpage is http://www.codeproject.com/Members/Shivamkalra[^] And Article that I want to get removed from is Vision on Virtual Commands[^] Please help. Regard, Shivam Kalra :)
-
Updating console textbox from multiple threadsHi, thanks for the reply. Will this code make sure that even if I invoke it through multiple threads..may be 5 threads then will be able to print all 5 of them on the console text box? And if "yes" then could you put more light on how it does that? I thought code should have been more complicated but it looks just one sentence thing?
-
Updating console textbox from multiple threadsHello everyone, I've made a multithread data base application, which is collecting data from multiple data bases from different threads and then process it and notifies the result on GUI. I've made a console which is just a big text box. Now, my question is that what is the best way to update a single GUI component from multiple threads. So far, I've made class called
class IOConsole
which constains a variable calledstatic Queue(String message)
and a methodpublic static println(string str)
and then I've added a background worker in GUI thread which keep looping and checks ifqueque
is empty or not and if not empty then it pop the string and print it on the GUI. To me its does't look very nice approach, not sure if it might be. But could I get some suggestion about how can I achieve this most efficiently. Thanks, Shivam Kalra :) -
Parsing HTML of some website using C Sharp.Hello everyone, I'm working on a small hobby project. I'm making a web crawler for a particular website to extract some useful information from it. I've written information extraction algorithms but I'm completely new to HTTP response stuff. I'm using a HttpWebResponse class of .Net to get the source code of a webpage in form of StreamReader. Now, I'm wondering if I should process each line of stream or I should convert whole streamReader to a string and then process that. Let say, I'm looking for string that should be able to extract .mp3 links on webpage using regex then is it possible that a single link is on two differnt lines of StreamReader, look at the code below..
string url = "http://songs.pk"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); StreamReader sr = new StreamReader(response.GetResponseStream()); string line; while ((line = sr.ReadLine()) != null) {
// Add some processing code here
Console.Read();
Console.WriteLine(line);
}Now can I add some regex matching code here..will this code make sure that it will be able to extract all the .mp3 links from this website? Or should I convert the StreamReader to string and then use regex matching on that string? I'm sorry, if I'm misunderstanding about StreamReader here, but I need some suggestions to parse the source code of a website. I've searched articles and Google but I'm unable to find something that could help me. Any articles, links or suggestions would be appreciated. Thanks Shivam Kalra
-
DllImport issue in c sharpYes off course. I'm just using it as a checking statement..if it doesn't exit then I don't import the dll. :) By the way I just finished the project I was working on. I'm not publicizing but here is the link to my blog post. http://shivam-kalra.blogspot.com/2011/05/using-in-build-accelerometer-in-lenovo.html[^] And thanks for the help! Shivam Kalra :)
-
DllImport issue in c sharpThank you guys. I also found another way of doing it using Files.Exists method of .net.
-
DllImport issue in c sharpHello everyone, I'm making a program that works on some lenovo laptops only, it makes use of Sensor.dll. I've used code below:
[DllImport("sensor.dll")]
private static extern void ShockproofGetAccelerometerData(ref APSReading accData);I'm not sure how should I check if it exits on the system or not. I'm using lenovo laptop therefore program works fine on my system but If someone runs on different system then it should show a message "system doesn't support" or some other error message. Is it possible to check if certain dll is present in system before importing it?? Thank you Shivam Kalra :)
-
Share your Net Speed?Faster than 94% of NL. Damn, New Zealand is at some next level in Internet speed compared to Canada.
-
Share your Net Speed?Check out my internet speed. Anybody got faster then it? http://speedtest.net/result/1303444377.png[^] Go to http://speedtest.net/[^] for the image of your net-speed test.
-
Get name of system folder [using C#]YUPPII. I solved the problem. I searched my name inside the registry and found that everyone is school has same registry key to that their name as registry value..so in my program I'm reading the registry value from this registry key..and it is working fine..thanks everyone again.. SHIVAM :)
-
controlling the AND gate with c#This better way of getting 1.
value += (int)(Math.Pow(Math.Sin(3.2), 2) + Math.Pow(Math.Cos(3.2), 2) + (8 / Math.Floor(8.7)) - 1);
-
controlling the AND gate with c#I would suggest you to read this article, it it very helpful. I made something very similar last year, to control LEDs from the parallel port, and this article helped me a lot. I/O Ports Uncensored - 1 - Controlling LEDs (Light Emiting Diodes) with Parallel Port[^]
-
Get name of system folder [using C#]Very strange but I do not see this folder anywhere on my computer. It shows when I press windows button or when I'm choosing or opening some file. I tried
Environment.UserName
but it is showing my student ID [LOL]. Anyways thanks, I checked your link, probably this what happening in my case too. DAM IT, but there has to be some folder which starts with my name. Shivam -
Get name of system folder [using C#]I tried your code. I get "C:\Users\100xxxxxx\Desktop" where 100xxxxxx is my student ID. I'm using .Net 3.5 but I do have .Net 4 with visual studios 10. Not why it is not working for me.. S
-
Get name of system folder [using C#]Hi, nothing seems to work. I tried your way, it only shows some other folder on my desktop.