Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
A

abiemann

@abiemann
About
Posts
73
Topics
25
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • debugging app to find out which code module doesn't decrease a count
    A abiemann

    Roger, thanks for your reply. my initial problem statement is a little bit simplified... in actuality the two calls vary wildly in the project. For example, 110 inc's and 140 dec's. However, with the aid of some flags and using an array to track which modules are making the calls I have been able to balance the code such that dec count == inc count by the time the executable is finished. I am actually really pleased with the implementation. So much so that I will keep the code in place and let it trigger only when an environment variable is set so that I can debug this problem if it shows up again :-)

    C / C++ / MFC question c++ help

  • debugging app to find out which code module doesn't decrease a count
    A abiemann

    I went with your idea of passing in an ID. The integer ID is used by the counting functions to track which module the call came from (keeps track with an array). with this method I can track what modules inc's and dec's don't match up.

    C / C++ / MFC question c++ help

  • debugging app to find out which code module doesn't decrease a count
    A abiemann

    I see, your method uses each bit in P to track a different code module. That's less work than implementing a linked list and I don't have to edit a load of compiler conditionals. EDIT: I counted 43 code modules that need to be ID'd

    modified on Wednesday, May 19, 2010 5:29 PM

    C / C++ / MFC question c++ help

  • debugging app to find out which code module doesn't decrease a count
    A abiemann

    my current idea is to define the following with #ifdef _DEBUG playing a huge role: in the class: #ifdef _DEBUG static Uint32 incCount (char cModule); static void decCount (char cModule); #else static Uint32 incCount (); static void decCount (); #endif the class where these functions are defined also implements a linked list. For each incCount(char) the char is added to the linked list (if it doesn't yet exist in the list), and for each decCount(char) the char is removed from the linked list. then for each time the functions are called in the code: #ifdef _DEBUG decCount(__FILE__); #else decCount(); #endif At the end of the program I dump what's in the linked list and the __FILE__ that is dumped is where I need to focus on by setting breakpoints. However, this will touch at least 40 files. Is this the best method or is there a better method ? For example, it would be incredible if I had programmatic access to the call stack (in a debug build) so that I would only need to edit this one class and add the source file to the linked list that's next in the stack.

    C / C++ / MFC question c++ help

  • debugging app to find out which code module doesn't decrease a count
    A abiemann

    This c++ application has two static functions that are used everywhere (about 130+ calls for each function): incCount() and decCount() At the start of the program the Count = 0, the problem is that once the processing is complete the Count must == 0. The Count can go as high as it needs to, but by the time the application ends each incCount() call must be balanced with a decCount() call. Currently, the Count == 1 by the time the program ends and I must find out where a decCount() isn't called. What is the best way to find out which code module isn't balancing the Count properly ? (this is a C++ 6 application)

    C / C++ / MFC question c++ help

  • How do I ensure that my thread is ready before my main thread continues ?
    A abiemann

    that works great =) thanks, Alan N

    C# question sysadmin data-structures

  • How do I ensure that my thread is ready before my main thread continues ?
    A abiemann

    I'm currently experiencing a race condition: my data-receive thread isn't ready by the time it's supposed to receive data

                    //create a thread to receive responses from the server
                    Thread clientThread = new Thread(new ParameterizedThreadStart(ProcessServerResponse));
                    clientThread.Start(RDclient);
    
                    //log activity to client window
                    logText("Connected to Server");
    
                    //initiate password syncronization - ProcessServerResponse() should be up and running by now
                    //TODO eliminate race condition
                    String clientRequest = "SYNC|" + strClientPassword;
                    Byte\[\] sendBytes = Encoding.ASCII.GetBytes(clientRequest);
                    tcpClientStream.Write(sendBytes, 0, sendBytes.Length);
                    tcpClientStream.Flush();
    

    how do I ensure that my ProcessServerResponse() thread is at the .Read() before my main thread sends .Write ?

        private void ProcessServerResponse(object client)
        {
            TcpClient \_RDclient = (TcpClient)client;
            NetworkStream tcpClientStream = \_RDclient.GetStream();
            String strTemp;
    
            //data array to receive data
            byte\[\] message = new byte\[Properties.Settings.Default.iReceiveBufferSize\];
            int iBytesReceivedCount;
    
            while (true)
            {
                iBytesReceivedCount = 0;
    
                try
                {
                    //blocks thread until server receives a message
                    iBytesReceivedCount = tcpClientStream.Read(message, 0, message.Length);
                }
    
    C# question sysadmin data-structures

  • how to waiti for specific events that occurs
    A abiemann

    you are correct by saying that the worker thread should be event-driven and should not poll... I have used the following example to learn from: Bounded Blocking Queue (One Lock)[^] and within your worker thread (it must be a thread that is started in the constructor) use:

            while (true)
            {
    
                lock (syncRoot)
                {
                    //block the thread until there is a message in the queue
                    while (iCount <= 0)
                        Monitor.Wait(syncRoot);
    
                    //there is work to do, lets dequeue and process it
                    class\_Message MessageWorker = messageQueue.Dequeue();
                    iCount--;
    

    .
    .
    .

    this has worked out really well and eventhough it's a blocking queue it works nice and fast !

    C# tutorial data-structures

  • (NegotiateStream) The server has rejected the client credentials
    A abiemann

    I found an example where the client specifies credentials: http://msdn.microsoft.com/en-us/library/system.net.security.protectionlevel.aspx[^] but I'm not happy that the client needs to know the username and password of the machine that the server is running on. If I have to store username and password for various machines in my exe.config then that seems impractical. I guess I will just go back to using TcpClient.Connect() and encrypting the data myself prior to transmission. :((

    C# csharp security tutorial visual-studio com

  • (NegotiateStream) The server has rejected the client credentials
    A abiemann

    I've followed the following tutorial: http://msdn.microsoft.com/en-us/library/system.net.security.negotiatestream%28VS.80%29.aspx[^] and have implemented a server and client application. :) When I use the client to connect to the server on the same machine (i.e. the IP is 127.0.0.1) it makes a secure connection. :) When I use the client on my XP machine to connect to the server on my Vista machine then the line:

    authStream.EndAuthenticateAsServer(ar);

    fails with the exception I pasted into the subject of this post. :( What I want to do is allow any client on any machine over the internet or LAN to connect to my server on port 9000 over an encrypted connection. I would be happy if I could allow the client to specify a username and password - but I don't know how to implement that functionality. details on the exception: $exception

    - $exception {"The server has rejected the client credentials."} System.Exception {System.Security.Authentication.InvalidCredentialException}

    •   \[System.Security.Authentication.InvalidCredentialException\]	{"The server has rejected the client credentials."}	System.Security.Authentication.InvalidCredentialException
      
    •   Data	{System.Collections.ListDictionaryInternal}	System.Collections.IDictionary {System.Collections.ListDictionaryInternal}
        HelpLink	null	string
      
    •   InnerException	{"The logon attempt failed"}	System.Exception {System.ComponentModel.Win32Exception}
        Message	"The server has rejected the client credentials."	string
        Source	"System"	string
        StackTrace	"   at System.Net.Security.NegoState.EndProcessAuthentication(IAsyncResult result)\\r\\n   at System.Net.Security.NegotiateStream.EndAuthenticateAsServer(IAsyncResult asyncResult)\\r\\n   at RemoteDiagnostics.Server.class\_RDServer.EndAuthenticateCallback(IAsyncResult ar) in C:\\\\Users\\\\Nuclear\\\\Documents\\\\Visual Studio 2008\\\\Projects\\\\RemoteDiagnostics\\\\RemoteDiagnostics\\\\Server\\\\class\_RDServer.cs:line 280"	string
      
    •   TargetSite	{Void EndProcessAuthentication(System.IAsyncResult)}	System.Reflection.MethodBase {System.Reflection.RuntimeMethodInfo}
      

    authStream

    - authStream {System.Net.Security.NegotiateStream} System.Net.Security.NegotiateStream

    •   base	{System.Net.Security.NegotiateStream}	System.
      
    C# csharp security tutorial visual-studio com

  • can TcpClient :: GetStream() be used in separate threads for the same TcpClient ?
    A abiemann

    passing the TcpClient object around and calling GetStream() once in the read thread and once in the write thread worked just fine. Since I found this out I have updated my code to use a secure socket and now I'm passing around a NegotiateStream object (but no need to call GetStream) :)

    C# question sysadmin

  • can TcpClient :: GetStream() be used in separate threads for the same TcpClient ?
    A abiemann

    my server implements a reading thread that blocks until data is received. what I'd like to do is have a designated thread that only writes as data becomes available (an event would be created that contains the TcpClient in the event argument). Therefore the question: is it possible to use TcpClient.GetStream() twice for the same TcpClient ?

    C# question sysadmin

  • Read and Write a file at the same time?
    A abiemann

    a service with a queue seems like an awesome idea for production code; you could add logging and keep adding all sorts of features as the requirements of the other applications change. I personally have used a MemoryMapped file to exchange data between two applications because I hate using the HDD for temporary data. EDIT: for an example of a memorymapped file: http://msdn.microsoft.com/en-us/library/dd997372%28VS.100%29.aspx[^]

    modified on Monday, November 23, 2009 6:45 PM

    C# csharp question

  • need help with adding a worker thread to my singleton
    A abiemann

    "protected" is how Microsoft showed the singleton pattern on MSDN

    C# help question csharp linq data-structures

  • need help with adding a worker thread to my singleton
    A abiemann

    My original intent in creating the message queue as a singleton was purely for good design. Now I'll rework the class and simply ensure that the class isn't instantiated more than once.

    C# help question csharp linq data-structures

  • need help with adding a worker thread to my singleton
    A abiemann

    purpose I am implementing a singleton "message queue". Several threads will enqueue messages to this queue and the worker thread will dequeue messages and process the message. problem in the line: "instance.threadWorker = new Thread(new ThreadStart(MessageWorker));" causes the error... "An object reference is required for the non-static field, method, or property 'Application_Messaging.class_MessageQueue.MessageWorker()'" code

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading;

    #pragma warning disable 0628 //suppress "new protected member declared in sealed class"

    namespace Application_Messaging
    {
    //singleton class because we only want one message queue
    // note: A sealed class cannot be inherited
    public sealed class class_MessageQueue
    {

        private static class\_MessageQueue instance = null;
        private static readonly object padlock = new object();
        private Thread threadWorker;
    
        //this is a singleton, only the Instance property may be used
        protected class\_MessageQueue()
        {
        }
    
        //property to get an instance to the class
        public static class\_MessageQueue Instance
        {
            get
            {
                lock (padlock)
                {
                    if (instance==null)
                    {
                        instance = new class\_MessageQueue();
    
                        instance.threadWorker = new Thread(new ThreadStart(MessageWorker));
                        instance.threadWorker.Start();
                    }
                    return instance;
                }
            }
        }
    
        private void MessageWorker()
        {
            //will be a loop to dequeue messages
        }
    
    
    }//end of: class class\_MessageQueue
    

    }//end of: namespace

    how can I get the worker thread running ?

    C# help question csharp linq data-structures

  • can an Access DB and a SQLce DB be used by multiple people simultaneously ?
    A abiemann

    the Access DB is used to only store data and it will be located in some shared folder on the network. There's about 10 client apps (which is probably what you meant by "front end") that will, at any point of time, read data from the database and also write data to the database. Forms will not be implemented in the database directly.

    Database database sysadmin question

  • can an Access DB and a SQLce DB be used by multiple people simultaneously ?
    A abiemann

    I always assumed that accessing the same Access database by multiple users somehow just works, i.e. many users can read and write to an Access database in a shared folder on the network. I assumed the same functionality with SQLce. However, I've never been able to test it. Does it work as I assumed ?

    Database database sysadmin question

  • problem with System.InvalidOperationException - enabling buttons from within event sub
    A abiemann

    Hi Luc, I've tried it, but WPF seems to be different because I get the error: InvokeRequired' is not a member of 'System.Windows.Controls.StackPanel so I'll try something like this: http://blog.somecreativity.com/2008/01/10/wpf-equivalent-of-invokerequired/[^]

    Visual Basic help database wpf

  • problem with System.InvalidOperationException - enabling buttons from within event sub
    A abiemann

    I then decided an alternative might be just to disable and enable the stackpanel on the Window1

    Private Sub StackPanel\_ButtonClick(ByVal sender As Object, ByVal e As RoutedEventArgs)
        Me.StackPanel1.IsEnabled = False 'instead of individually disabling buttons in each control on the stackpanel
        MSVMobject.StartVM()
    End Sub
    
    Friend Sub MSVM\_VMexited()
        Me.StackPanel1.IsEnabled = True
    End Sub
    

    However, "Me.StackPanel1.IsEnabled = True" still caused the exception X| :(( :confused:

    Visual Basic help database wpf
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups