Jump to content

Check out our Community Blogs


Member Since 09 Apr 2012
Offline Last Active Apr 07 2018 09:59 PM

#640653 Best way to detect next day

Posted by AceInfinity on 03 October 2012 - 07:02 PM

I have all the data for my application loaded into memory already so holding the DateTime object in memory is not up for debate

I disagree, and not to be rude, but I truly think it is up for debate ;) , unless you're absolutely willing to reject any evidence and advice given by others in this thread, I have a hard time believing that you're storing more than 70 000-100 000K in memory just for your one program... If you do, then there's something you're doing which is seriously wrong. Either way, storing ONE DateTime object in memory as a reference will NOT hurt anything.

You seem to be worried about memory usage for your application. I can honestly say that storing a DateTime object vs. instantiating a whole FileStream will be less of a burden on memory here.

:c-penguin: Cheers

You misunderstood the data I was saving and how I was saving it.

Good thing C# has garbage collection right?

Check out the app I am making here

No, I understood how you were saving it, but I misunderstood what data you were saving other than a DateTime object because you did not clearly specify the full scope of your program. Yes C# has GC, but understanding when and what it cleans up is important. If you assume it'll do everything for you, you'll have a heck of a time optimizing programs when managing unmanaged resources... This is what i'm trying to explain to you. You need to also make sure that you're properly disposing of your objects which implement the IDisposable interface. (Specifically from what I can assume about your program; objects that use FileStreams. Don't forget!)

lol, read what i've posted! :rules:

I'm not here to battle you, the reason why I joined the discussion in this thread was to help you. Please do not misinterpret that. If you take my advice for what it is, I have good reason and intention for why I say what I do. Those who keep a closed mind, won't learn much more than they already know. It's good to learn from others, and I do have some experience that I enjoy sharing with others, if they so choose to accept my words; suggestions, recommendations, and other advice.

Cheers :thumbup1:
  • -1

#640352 [ Solved ] moving 2 controls(picturebox) in the same time

Posted by AceInfinity on 30 September 2012 - 10:10 PM

Why don't you create the mouse pictureboxes dynamically on separate threads? You won't be able to process moving both at the same time even on separate threads because you'll be required to Invoke back to the UI thread to take action anyways.
  • 1

#639035 How to kill a process by process description and even more ?!

Posted by AceInfinity on 17 September 2012 - 03:42 PM

If you want to use the traditional way you can do this:

Function GetProcessesByDescription(ByVal description As String) As Process()
Dim result As New List(Of Process)
For Each p As Process In Process.GetProcesses

Dim ProcessFile = FileVersionInfo.GetVersionInfo(p.MainModule.FileName)
Dim myDescription = ProcessFile.FileDescription

if (myDescription = description) then result.Add(p)

Catch ex As Exception
'If ex.Message = "Access is denied" Then
'MsgBox("Access is denied")
'End If
End Try
Return result.ToArray()
End Function

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim SUNProcess() As Process = GetProcessesByDescription("Notepad")
For Each pro As Process In SUNProcess
End Sub

hope this helps

That's essentially exactly what my code does only I used LINQ. He'll have the same Win32Exception because of the fact that it's basically the same thing.
  • 1

#638951 How to kill a process by process description and even more ?!

Posted by AceInfinity on 16 September 2012 - 09:16 PM

Here's a .NET way, although you may encounter some Win32Exception's.

Dim Desc As String = "windows media player"
Dim FindProc As Process = Process.GetProcesses().FirstOrDefault(Function(p) Regex.IsMatch(p.MainModule.FileVersionInfo.FileDescription, Desc, RegexOptions.IgnoreCase))
If FindProc IsNot Nothing Then FindProc.Kill()

thanks alot but it did not work for me .

i run it without any error but when i tested it for mor 15 app , the message "Access is Denied" apears !

it did not kill even 1 application !

please help me , what should i do ?



although you may encounter some Win32Exception's.

Although this is because of the accessibility from a x86 solution to 64 bit process modules from my experience.
  • 1

#638926 C# string to executed code

Posted by AceInfinity on 16 September 2012 - 04:40 PM

Funnily enough I created an application that does this a while back :)


Posted Image
  • 1

#636765 Expandable listview row in .NET

Posted by AceInfinity on 23 August 2012 - 07:28 PM

Maybe Treelistview but ... I am looking for a result like this:

+ one | two | three |
- four | five | six
- seven | eight | nine |
+ ten | eleven | twelve |

Treeview cant do this I think.

A "TreeListView"..?

No, a TreeView control can do that.
  • 1

#636673 C# Robotics

Posted by AceInfinity on 22 August 2012 - 08:12 PM

If you want something interesting to look at take a look at this link: http://www.microsoft.com/robotics/
  • 1

#636346 Create a button that will open another page

Posted by AceInfinity on 18 August 2012 - 12:57 PM

I know it may cause problems, but when you start typing, you'll see the real Form3 and the class Form3, and select it ;)

No, Form3 (by itself) actually now becomes a local variable when you do that:

Posted Image
  • 1

#636294 Create a button that will open another page

Posted by AceInfinity on 17 August 2012 - 10:02 PM

Well, if your options form in a new form called Form3

You'll make a code like this

Form3 Form3 = new Form3();

Sorry if that wasn't the answer, but maybe i didn't understand your point!

Don't name your variables the same as the name of the class for that particular Form. Now how do you differentiate between the 2? Form3 isn't the class Form3 anymore. ALWAYS remember to use unique identifiers...
  • 1

#635125 Generation / Combination Of Text From Inputs?

Posted by AceInfinity on 03 August 2012 - 04:17 PM

Hmmm I really don't know which solution is faster but I think it's the same sh..
I was just giving another solution that is also good. It would be good to practice both solutions.

It's good to know about Lists and Arrays yes, I agree, along with basic string concatenation like in your method. In this case though by personal preference I would prefer String.Format(). It keeps things more tidy in my mind. What you posted though is okay. :)
  • 1

#635119 Generation / Combination Of Text From Inputs?

Posted by AceInfinity on 03 August 2012 - 03:10 PM

Where did I say it is similar to an array?
And why do you think kotg solution is the only?

You should read the thread. I did not say that you said it was similar to an array, read what OP said here though: http://forum.codecal...ts/#entry634962

I was replying to him, not you.

And why do you think kotg solution is the only?


But don't get the wrong idea here. I also didn't say that any solution was the only solution. There's always more than one way of doing something in programming, some are better than others, but in this case I honestly believe that String.Format is the way to go. It's much faster than having to create an array and concat the elements after the fact, which makes it optimized for what OP is trying to do. Performance-wise, it's probably the best way of doing this here. You're only left with one string value in the end, and the other elements (string's) don't have to be added to an array, to create a new concatenated string after the fact.

I'm just showing you why I would recommend String.Format here. That's the method I posted, but with reason's behind it.

EDIT: What you posted is essentially close to the same thing, the idea behind it is literally almost identical to what i've posted and the other guy before me.
  • 1

#635033 Generation / Combination Of Text From Inputs?

Posted by AceInfinity on 02 August 2012 - 06:25 PM

To what another had already posted, String.Format is the way to go here:
string name, age, hobby;
string result = string.Format("Hello my name is {0} and I am {1} years old. I enjoy to {2} in my free time.", name, age, hobby);

And it's not similar to an array, there's no collection of elements anywhere in this code, we're formatting one string value here, parsing the string's name, age, and hobby, into the sentence.
  • 1

#634705 Question: How To Protect My C# Code From Being Decompiled?

Posted by AceInfinity on 27 July 2012 - 02:53 PM

Decompiling using what? .NET Reflector, or something as far as Olly or IDAPro? For .NET Reflector protection, it's as simple as a PE header edit....
  • 1

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download