15,921,941 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Visual Basic questions
View Javascript questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Member 11175072 (Top 15 by date)
Member 11175072
21-Jan-15 21:28pm
View
I had read this article,it is written in C++ which is new to me,what's more,I can only receive the WM_DEVICECHANGE message with wParam set to DBT_DEVNODES_CHANGED and lParam set to zero,Can I get more infomation about the device by using DEV_BROADCAST_HDR structure and checking its dbch_devicetype member?.I want to be notified when the device was plugged out the PC.
Member 11175072
29-Dec-14 8:11am
View
Can you give me some code?
Member 11175072
27-Dec-14 8:23am
View
Much thanks
Member 11175072
27-Dec-14 8:15am
View
Much thanks for your suggestion.
Member 11175072
25-Dec-14 23:32pm
View
Yes,it is in Win7,I want to be notified when the tablet has connected to the PC and than I can trigger something.
Member 11175072
25-Dec-14 23:28pm
View
I want to asking for detection on the Windows side,The Table PC refers to the tablet.
Member 11175072
25-Dec-14 10:01am
View
So I think when a thread enter a sleeping state,you can not suspend the thread.
Member 11175072
25-Dec-14 9:57am
View
I am learning the threading these days,I just want to make use of the Suspend method and
the Resume() method for learning how to control the thread.I encountered this problem by accident.
Member 11175072
25-Dec-14 9:15am
View
Sorry,I will keep it in mind later.
Member 11175072
25-Dec-14 9:14am
View
I want to create a thread to execute a function need some time,When has completed something the thread will sleep for some time,I created a button called cmdPause,sometimes I clicked the button it will call the Suspend() method to suspend the thread,However sometimes the buttons will not work,I think the thread is sleeping.How can I solve this problem?
Member 11175072
25-Dec-14 9:08am
View
Deleted
Here some code:
private void cmdStart Click(object sender, System.EventArgs e)
{
// Let's create a new thread
primeNumberThread = new Thread(
new ThreadStart(GeneratePrimeNumbers));
// Let's give a name for the thread
primeNumberThread.Name = "Prime Numbers Example";
primeNumberThread.Priority = ThreadPriority.BelowNormal;
// Enable the Pause Button
cmdPause.Enabled = true;
// Disable the Start button
cmdStart.Enabled = false;
// Let's start the thread
primeNumberThread.Start();
}
private void cmdPause Click(object sender, System.EventArgs e)
{
try
{
try
{
// If current state of thread is Running,
// then pause the Thread
if (primeNumberThread.ThreadState ==
System.Threading.ThreadState.Running)
{
//Pause the Thread
primeNumberThread.Suspend();
//Disable the Pause button
cmdPause.Enabled = false;
//Enable the resume button
cmdResume.Enabled = true;
}
}
catch(ThreadStateException Ex)
{
MessageBox.Show(Ex.ToString(), "Exception",
MessageBoxButtons.OK, MessageBoxIcon.Error,
MessageBoxDefaultButton.Button1);
}
}
private void cmdResume Click(object sender, System.EventArgs e)
{
if(primeNumberThread.ThreadState ==
System.Threading.ThreadState.Suspended ||
primeNumberThread.ThreadState ==
System.Threading.ThreadState.SuspendRequested)
{
try
{
// Resume the thread
primeNumberThread.Resume();
// Disable the resume button
cmdResume.Enabled = false;
// Enable the Pause button
cmdPause.Enabled = true;
}
catch(ThreadStateException Ex)
{
MessageBox.Show(Ex.ToString(), "Exception",
MessageBoxButtons.OK, MessageBoxIcon.Error,
MessageBoxDefaultButton.Button1);
}
}
}
public void GeneratePrimeNumbers()
{
long lngCounter;
long lngNumber;
long lngDivideByCounter;
bool blnIsPrime;
long[] PrimeArray = new long[256];
// initialize variables
lngNumber = 3;
lngCounter = 2;
// We know that the first prime is 2. Therefore,
// let's add it to the list and start from 3
PrimeArray[1] = 2;
lstPrime.Items.Add(2);
while(lngCounter < 256)
{
blnIsPrime = true;
// Try dividing this number by any already found prime
// which is smaller then the root of this number.
for(lngDivideByCounter = 1; PrimeArray[lngDivideByCounter]
* PrimeArray[lngDivideByCounter] <= lngNumber;
lngDivideByCounter++)
{
if(lngNumber % PrimeArray[lngDivideByCounter] == 0)
{
// This is not a prime number
blnIsPrime = false;
// Exit the loop break;
}
}
// If this is a prime number then display it
if(blnIsPrime)
{
// Guess we found a new prime.
PrimeArray[lngCounter] = lngNumber;
// Increase prime found count.
lngCounter++;
lstPrime.Items.Add(lngNumber);
// Let's put the thread to sleep for 100 milliseconds.
// This will simulate the time lag and we'll get time
// to pause and resume the thread
Thread.Sleep(100);
}
// Increment number by two
lngNumber += 2;
}
// Once the thread is finished execution enable the start
// and di
Member 11175072
23-Dec-14 8:22am
View
Thanks anyway,though I just detect a USB flash disk rather a tablet.
Member 11175072
23-Dec-14 8:21am
View
Deleted
I can not made it
Member 11175072
6-Dec-14 7:01am
View
Thanks for your example!
Member 11175072
6-Dec-14 7:01am
View
Much Thanks!
Show More