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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
C

charian0920

@charian0920
About
Posts
11
Topics
5
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Serialize/Deserialize data class from different assemblies
    C charian0920

    hi occcy, thanks for your explanation. that's the way i understand it also. but the current project that i'm working on, in the interface/abstract class they only have the get. then the set is in the implementation dll.

    // API.dll:
    public interface IDataClass {
    int DataField { get; }
    }

    // APIIMPL.dll:
    public class DataClass: IDataClass {
    private int dataField;
    public int DataField { get { return dataField; } set { dataField=value;} }}

    is there any tweak that i can implement for this to work in remoting??

    C# help csharp algorithms testing business

  • Serialize/Deserialize data class from different assemblies
    C charian0920

    Hi gurus, I'm new to .NET Remoting and I have this problem. I have an assembly, API.dll, that contains all the abstract functions and data classes. I have a separate assemby, APIImpl.dll, that overrides the functions and data classes. Let's focus on my this one: One of my abstract data class in API.dll is read-only, meaning it only have the getter. The setter of this data class is in APIImpl.dll. I wanted to implement remoting to cater for some requirements. I made all my data classes Serializable. However, when i tried testing the remoting that i implemented, I encountered a SerializationException and the message is 'Unable to locate APIImpl.dll'. From what I understand about remoting is that the implementation dll does not necessarily to be in the client machine. But base on the exception that I encountered, in the client application it's still searching the implementation assembly. Please help. :( Thanks in advance.

    C# help csharp algorithms testing business

  • Namedpipe
    C charian0920

    hi mark, yup I already did that ... the funny thing is that the spawned thread is terminating when I run it with breakpoints and when I put messageboxes.

    C / C++ / MFC help sysadmin algorithms security testing

  • Namedpipe
    C charian0920

    Hi! Good day :) I have this problem about synchronization on namedpipe ... I have this namedpipe server that allows multiple instances. The algorithm I have is I'll wait for a client to connect to the namedpipe then spawn a thread which will read the message from the namedpipe. My expectation on the spawned thread is that when the client has disconnected the spawned thread will end also. But when I tried testing my code, the thread count keeps on increasing due to the spawned thread, which i think means I was not able to detect that the client had disconnected or something else :( Any help is greatly appreciated. Below are my codes: 1. Createnamedpipe, wait for a client to connect, and spawned a thread. UINT fnRcvMsgsFrmNamedpipeThread(LPVOID pParam) { DWORD dwResult = SUCCEED; CString strLog( _T( "" ) ); OVERLAPPED stClientConnectOverLap = {0}; stClientConnectOverLap.hEvent = CreateEvent( NULL, // no security attributes TRUE, // manual reset event FALSE, // not-signalled NULL); // no name if( stClientConnectOverLap.hEvent == NULL ) { return 0; } HANDLE hEvents; hEvents = stClientConnectOverLap.hEvent; CString strFormatPipeName( _T( "" ) ); strFormatPipeName.Format( "\\\\%s\pipe\mypipename", STR_PERIOD ); HANDLE hClientReqPipe; while ( TRUE ) { hClientReqPipe = CreateNamedPipe( strFormatPipeName, FILE_FLAG_OVERLAPPED | PIPE_ACCESS_DUPLEX, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, PIPE_UNLIMITED_INSTANCES, 0, 0, 10000, NULL ); if( hClientReqPipe == INVALID_HANDLE_VALUE ) { dwResult = GetLastError(); break; } if( !ConnectNamedPipe( hClientReqPipe, &stClientConnectOverLap ) ) { if( GetLastError() != ERROR_PIPE_CONNECTED ) { DWORD dwRet = WaitForSingleObject( hEvents, INFINITE ); if( dwRet != WAIT_OBJECT_0 ) { dwResult = GetLastError(); break; } } } CWinThread *pReadMsgThread = AfxBeginThread( fnReadMsgFrmNamedpipe, (LPVOID) hClientReqPipe ); if( NULL == pReadMsgThread ) { break; } } // Close handles ::CloseHandle( hClientReqPipe ); ::CloseHandle( stClientConnectOverLap.hEvent ); return dwResult; } 2. Spawned thread UINT fnReadMsgFrmNamedpipe(LPVOID pParam) { I32L dwResult = SUCCEED; CString strLog( _T("") ); HANDLE hClientReqPipe = (HANDLE) pParam; OVERLAPPED stClientRecOverLap

    C / C++ / MFC help sysadmin algorithms security testing

  • Namedpipe
    C charian0920

    I need to wait for all the namedpipe instance to be disconnected by the server first before my process exit. I tried again the code, I already getting "1" for the instance count. If the server already called the DisconnectNamedPipe(), shouldn't be the number of instance decreased? thanks again :) -- modified at 10:09 Tuesday 26th June, 2007

    C / C++ / MFC question sysadmin json

  • Namedpipe
    C charian0920

    hi mark, thanks for the suggestion. however, i tried searching it in the net and couldn't find any sample implementation that uses the GetNamedPipeHandleState API. I also tried coding like this: DWORD dwCurIntances; DWORD dwState; dwCurIntances = 0; dwState = 0; while ( TRUE ) { // Wait for all the namedpipe instances to close first if( !GetNamedPipeHandleState( (HANDLE) hClientReqPipe, &dwState, &dwCurIntances, NULL, NULL, NULL, 0 ) ) { dwResult = GetLastError(); strLog.Format( "@@@@@@@@@@@@@@@@@@@@ GetNamedPipeHandleState Error: %d.", dwResult ); fnAddToMessageLog( 0, strLog ); break; } if ( dwCurIntances == 0 ) { strLog.Format( "@@@@@@@@@@@@@@@@@@@@ All namedpipe instances have been closed." ); fnAddToMessageLog( 0, strLog ); break; } } but I think it does not go the way I expected it. I'm expecting that the value of dwCurIntances during the startup is "1", since I have created the namedpipe once only. the value I get is "7". would appreciate your help. thank you. :)

    C / C++ / MFC question sysadmin json

  • Namedpipe
    C charian0920

    Hi ... I'm using namedpipe for my interprocess communication. For each client that requires communication will have a separate instance of the namedpipe. My question is: is there an API that I could use to get the number of active instances of a namedpipe? I need this so that when my process ends it will wait first for the nedpipe server to disconnect before exiting my process. Thanks in advance ... :)

    C / C++ / MFC question sysadmin json

  • priority queue with time limit
    C charian0920

    First of all, I would like to thank you for your responses ... After reading your answer, I just found out that I'm still on the right track ... Thank goodness :) I just did the same concept after a lot of readings and research ... The only difference is that i don't sort (or call tha comparison) when the pop method is called. What I did was I created a worker thread that will call the sort(or call tha comparison) after a certain time had elapsed. In effect, I'll be re-sorting my queue on given a period of time. I'm not sure if this is the efficient way though ... Care to share your thoughts?? ;)

    C / C++ / MFC help c++ docker data-structures

  • priority queue with time limit
    C charian0920

    What i mean by age is the time that an item has lived in the queue. i only have the following for now ... 1. template class for my queue: template class ThreadSafePriorityQueue : public CComAutoCriticalSection { private: priority_queue > m_q; int m_intMaxSize; public: ThreadSafePriorityQueue() { m_intMaxSize = 10000; } ThreadSafePriorityQueue(int intMaxSize) { m_intMaxSize = intMaxSize; } ~ThreadSafePriorityQueue() { } bool push( const T& x ) { bool rtn = true; Lock(); if(m_q.size() > m_intMaxSize) { rtn = false; } else { m_q.push( x ); } Unlock(); return rtn; } bool pop( T& x ) { bool rtn = false; Lock(); if( !m_q.empty() ) { rtn = true; x = m_q.top(); m_q.pop(); } Unlock(); return rtn; } bool empty() { Lock(); bool rtn = m_q.empty(); Unlock(); return rtn; } T front() { Lock(); T rtn = m_q.top(); Unlock(); return rtn; } }; 2. Then I have this structure that i pushed to the queue typedef struct _StructPriorityRequest { int intPriority; StructRequest structMessage; bool operator < (const _StructPriorityRequest &structT2) const { return intPriority > structT2.intPriority; } } StructPriorityRequest; How should i modify my codes so i could consider the age of the item in the queue? Please help me ....

    C / C++ / MFC help c++ docker data-structures

  • priority queue with time limit
    C charian0920

    hi c++ guru. i need your help... i'm new in hardcore c++ and currently working on a c++ container namely the priority_queue. i don't have problem using the priority_queue itself but i have this additional requirement to also consider the age of the items in the queue. my current implementation only deals with the priority of the items in the queue by overloading the "<" operator. i don't know yet what to do when considering the age of the items in the priority_queue. any help is greatly appreciated... PS: sample code would be a great help... charian

    ATL / WTL / STL help c++ docker data-structures

  • priority queue with time limit
    C charian0920

    hi c++ guru. i need your help... i'm new in hardcore c++ and currently working on a c++ container namely the priority_queue. i don't have problem using the priority_queue itself but i have this additional requirement to also consider the age of the items in the queue. my current implementation only deals with the priority of the items in the queue by overloading the "<" operator. i don't know yet what to do when considering the age of the items in the priority_queue. any help is greatly appreciated... PS: sample code would be a great help... :) charian

    C / C++ / MFC help c++ docker data-structures
  • Login

  • Don't have an account? Register

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