16,004,587 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 Javascript questions
View Visual Basic questions
View .NET 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 Rick Shaub (Top 61 by date)
Rick Shaub
11-Jan-17 10:47am
View
Thanks for the feedback guys. I underestimated the complexity of this problem. I'll leave this up as an example of a wrong approach.
Rick Shaub
14-Sep-11 9:22am
View
Good tip. I was going to mention Enum.IsDefined, but it looks like you got it covered.
Rick Shaub
6-Jul-11 12:31pm
View
Teach them how to fish. 5.
Rick Shaub
14-Jun-11 17:07pm
View
Thanks!
Rick Shaub
24-May-11 13:48pm
View
Also acceptable: rutabagas.
Rick Shaub
17-May-11 14:34pm
View
I know. I'm refering to the OP's method signature. Control and EventArgs should be managed pointers.
Rick Shaub
17-May-11 13:17pm
View
I think you may want to change your method signature to all managed pointers except the int. Is the C++ code supposed to be an exact port of your C# code?
Rick Shaub
17-May-11 13:15pm
View
My 5. OP needs to clarify intent. Your other points are valid as well.
Rick Shaub
17-May-11 11:10am
View
Those two code snippets arent doing the same thing. Should they be?
Rick Shaub
13-May-11 11:34am
View
You should update your question to reflect that you want to use the files as embedded resources. It wasn't clear and would be helpful for anyone who stumbles across this in the future.
Rick Shaub
13-May-11 11:20am
View
You have to do some work yourself. Obviously you have to have a legitimate file path. I'm sure you could handle figuring that part out.
Rick Shaub
13-May-11 10:31am
View
Please read my answer carefully. It will work. You need to set the build options for each file to the correct settings. If you want to use reflection, I suggest you do the research yourself because it's less simple than this way.
Rick Shaub
13-May-11 10:23am
View
This is a one-way hash. You can't decrypt it. However, if you added a salt, this would be the prefereable way to store passwords.
Rick Shaub
13-May-11 10:04am
View
That article is a little dated and doesn't really show how to utilize the functionality of PictureBox objects.
Rick Shaub
12-May-11 10:59am
View
I Copy and pasted into Google translate. To my surprise, it's a howmework assignment!!! It looks like a math problem too :/
Rick Shaub
11-May-11 14:49pm
View
He wants to change the IP address. Seems pretty self-explanatory to me.
Rick Shaub
11-May-11 14:39pm
View
Ipconfig can't be used to change the IP address.
Rick Shaub
11-May-11 11:46am
View
Yes but it isn't a "static class", it's a static instance of a class. There's a difference.
Rick Shaub
11-May-11 9:58am
View
Yours is also very good!
Rick Shaub
11-May-11 9:50am
View
+5
Rick Shaub
11-May-11 9:38am
View
FYI from MSDN: "Guidelines for FlagsAttribute and Enum: ...
Define enumeration constants in powers of two, that is, 1, 2, 4, 8, and so on. This means the individual flags in combined enumeration constants do not overlap. ..."
This basically means that while it's possible to define non power of two Flags-decorated enums, it is not recommended.
Rick Shaub
10-May-11 23:16pm
View
He states clearly; " Enum.IsDefiend returns false if check for example two ored values...". This answer was already accepted, what's the problem? I don't think you understand the complexity. It's not simply find if a bit is in an enum, it's finding if an int matches any of the combination of bitwise ORs. My approach would work regardless of power-of-twos or not. I only used powers of twos to clearly demonstrate the principle. And FlagsAttribute has everything to do with bitwise OR. That's it's only purpose, to treat an enumeration as a bit field.
Rick Shaub
10-May-11 23:09pm
View
See my comment. Also note that I did not down vote.
Rick Shaub
10-May-11 23:05pm
View
The OP wants to check if an int is bitwise OR of two or more flags, or a value in his enum. This solution will not do that. This type of iterative approach is going to be O(2^n) because you have to check all combinations of flags before declaring the result false. You could build a table and perform a binary search, which would be probably optimal timewise. Here's a simple test case:
[Flags]
public enum FlagEnum
{
one=1,
two=2,
four=4,
eight = 8,
sixteen =16,
thirtytwo = 32
}
private void button1_Click(object sender, EventArgs e)
{
bool orly = IsIntInEnum(typeof(FlagEnum),(int)(FlagEnum.one|FlagEnum.thirtytwo));
}
Rick Shaub
10-May-11 21:54pm
View
I don't think this solves the OP's problem.
Rick Shaub
10-May-11 15:08pm
View
I agree it made me have to think outside the box.
Rick Shaub
4-May-11 15:15pm
View
It's good practice anyway. Even better to check if invoke is required and only invoke when required. Although, with UI code it's rarely a noticable improvement.
Rick Shaub
3-May-11 16:12pm
View
I think you miss what I'm saying. Make your primary key a GUID. Have a bit or a boolean flag that indicates whether the record has been processed and a date field to indicate when the record was entered. Do a query "where isProcessed != true order by timeProcessed" to get the records that need to be processed in order.
Rick Shaub
3-May-11 16:11pm
View
Deleted
I think you miss what I'm saying. Make your primary key a GUID. Have a bit or a boolean flag that indicates whether the record has been processed and a date field to indicate when the record was entered. Do a query "where isProcessed != true order by timeProcessed" to get the records that need to be processed in order.
Rick Shaub
3-May-11 12:42pm
View
You shouldn't be using a surrogate key to determine status. You should have some data element such as a time/date stamp for "record created" and a flag to indicate "record processed" or some other similar sdcheme.
Rick Shaub
3-May-11 11:09am
View
Can you please edit your question to include the code that is causing you problems?
Rick Shaub
2-May-11 14:18pm
View
If you include the header elsewhere, the linking process will fail in due to a previously defined variable, function etc.
Rick Shaub
29-Apr-11 11:29am
View
My 5. Also, you could use the "+" operator.
Rick Shaub
29-Apr-11 10:27am
View
That's the way you do it. 5
Rick Shaub
29-Apr-11 9:15am
View
Hi, some code snippets would be helpful here.
Rick Shaub
28-Apr-11 15:07pm
View
Good answer.
Rick Shaub
28-Apr-11 15:05pm
View
I wonder if he meant from ASCII to UTF-8. If so, you could have just said "Done!" ;)
Rick Shaub
28-Apr-11 10:59am
View
Thanks!
Rick Shaub
28-Apr-11 9:42am
View
Sounds like this could be a lot of things. maybe a problem with sun-jaxws.xml or web.xml? Here's a google search that may help: http://www.google.com/search?hl=en&q=failed+to+parse+runtime+descriptor%3A+runtime+modeler+error%3A+Wrapper+class+is+not+found.+Have+you+run+APT+to+generate+them%3F&aq=f&aqi=&aql=&oq=
Rick Shaub
27-Apr-11 14:03pm
View
Then you may want to use an AutoResetEvent Object. You can also use Mutexes or Semaphores. Look at my code to see how an AutoResetEvent is used.
Rick Shaub
27-Apr-11 13:38pm
View
No. System.Timer uses a threadpool thread for notifications unless you use a synchronizing object. You're not using a synchronizing object, are you?
Rick Shaub
27-Apr-11 13:36pm
View
You may want to edit your question and show more of your code so people can see exactly what you're doing. Also, can you explain what you are trying to do?
Rick Shaub
25-Apr-11 22:57pm
View
Just provide the url of the WSDL in the wizard. It should work unless there's a problem with the format of the file.
Rick Shaub
25-Apr-11 22:52pm
View
I don't see where you're setting the baud, parity bit, etc. DO you mean in a different method? Did you look at the second link? That shows how you should use Win32 to do serial communications. Also, look at Hans Dietrich's link. It contains important information about using serial port numbers higher than "COM9".
Rick Shaub
21-Apr-11 16:47pm
View
You can also call Read() into a byte buffer of arbitrary size. It won't block because we already know that there's data available.
Rick Shaub
21-Apr-11 11:11am
View
I agree 100%. What others may call "plain", I call "clean".
Rick Shaub
19-Apr-11 16:40pm
View
If you were worried about speed, you'd count by 100. Or not. I don't think it matters for this kind of code (test).
Rick Shaub
18-Apr-11 13:43pm
View
My 5. Great answer. I would make synclock readonly as well.
Rick Shaub
15-Apr-11 9:48am
View
Good link.
Rick Shaub
14-Apr-11 15:58pm
View
Oops. You're absolutely right.
Rick Shaub
14-Apr-11 12:43pm
View
Is the orphaning of the process intentional? If not you should call TerminateProcess() to end the process.
Rick Shaub
7-Apr-11 13:49pm
View
My 5. However, he needs to be careful with regards to WMI. You have to take a look at each object and property that you are using and make sure tha it's supported for whatever OS versions you want to support. Also, I believe WMI can be turned off, so that's also a consideration.
Rick Shaub
6-Apr-11 11:50am
View
Could you list the development environment and some information about the environment this program will run on? Information such as operating system, whether or not office is installed. Also, versioning information, i.e. Windows XP with Office 2007, etc.
Rick Shaub
28-Mar-11 16:35pm
View
He said JBossESB, which is Java.
Rick Shaub
25-Mar-11 12:15pm
View
Thanks!
Rick Shaub
24-Mar-11 11:48am
View
Good answer, although you shouldn't use lock(this) because external code can lock on this. Use a readonly object instead and lock on that.
Rick Shaub
24-Mar-11 10:35am
View
BeginThreadAffinity/EndThreadAffinity don't do the same thing as the OP asked.
Rick Shaub
23-Mar-11 20:35pm
View
I don't think this is a Compact Framework question.
Rick Shaub
23-Mar-11 12:55pm
View
FYI- I agree that in most cases it's a waste of time. I just answered his question. I also didn't 1 vote you.
Rick Shaub
23-Mar-11 11:23am
View
It should work especially if you are compiling on a 64 bit system. It looks like stack alignment can be troublesome in some cases see http://stackoverflow.com/questions/3046439/createthread-fails-on-64-bit-windows-works-on-32-bit-windows-why and http://msdn.microsoft.com/en-us/library/aa290049%28VS.71%29.aspx
Rick Shaub
22-Mar-11 17:11pm
View
Can you please post your code on this site?
Show More