Search Results

Search found 5 results on 1 pages for 'zhengzhiren'.

Page 1/1 | 1 

  • how to google a symbol keyword like "$?"

    - by ZhengZhiren
    i saw a trick in a book: in a linux shell, we can use &? to get the return value of a command. For example,we run a command,if it exit normally, the return value is 0. And then we type $?,we will get 0 in the screen. i want to google this kind of usage, so i have to type these two symbol $? in the search blank.But the search engine just return nothing to me... i have looked at the google help page, but still can't find a solution. so my question is: how can i search with this kind of keyword. or if you can give me some advise of the usage of $? or sort of thing, that will be also appreciated.

    Read the article

  • how do i know how many clients are calling my WCF service function

    - by ZhengZhiren
    i am writing a program to test WCF service performance in high concurrency circumstance. On client side, i start many threads to call a WCF service function which returns a long list of data object. On server side, in that function called by my client, i need to know the number of clients calling the function. For doing that, i set a counter variable. In the beginning of the function, i add the counter by 1, but how can i decrease it after the funtion has returned the result? int clientCount=0; public DataObject[] GetData() { Interlocked.Increment(ref clientCount); List<DataObject> result = MockDb.GetData(); return result.ToArray(); Interlocked.Decrement(ref clientCount); //can't run to here... } i have seen a way in c++. Create a new class named counter. In the constructor of the counter class, increase the variable. And decrease it in the destructor. In the function, make a counter object so that its constructor will be called. And after the function returns, its destructor will be called. Like this: class counter { public: counter(){++clientCount; /* not simply like this, need to be atomic*/} ~counter(){--clientCount; /* not simply like this, need to be atomic*/} }; ... myfunction() { counter c; //do something return something; } In c# i think i can do so with the following codes, but not for sure. public class Service1 : IService1 { static int clientCount = 0; private class ClientCounter : IDisposable { public ClientCounter() { Interlocked.Increment(ref clientCount); } public void Dispose() { Interlocked.Decrement(ref clientCount); } } public DataObject[] GetData() { using (ClientCounter counter = new ClientCounter()) { List<DataObject> result = MockDb.GetData(); return result.ToArray(); } } } i write a counter class implement the IDisposable interface. And put my function codes into a using block. But it seems that it doesn't work so good. No matter how many threads i start, the clientCount variable is up to 3. Any advise would be appreciated.

    Read the article

  • How could my code compliled correctly without necessary headers?

    - by ZhengZhiren
    I use the functions fork(),exec()... But how can this program compiled without including some extra headers(like sys/types.h, sys/wait.h). I use ubuntu 10.04 with gcc version 4.4.3 #include <stdio.h> #include <stdlib.h> int main() { pid_t pid; printf("before fork\n"); pid = fork(); if(pid == 0) { /*child*/ if(execvp("./cpuid", NULL)) { printf("error\n"); exit(0); } } else { if(wait(NULL) != -1) { printf("ok\n"); } } return 0; }

    Read the article

  • how to google a symbol keyword like "$?"

    - by ZhengZhiren
    i saw a trick in a book: in a linux shell, we can use &? to get the return value of a command. For example,we run a command,if it exit normally, the return value is 0. And then we type $?,we will get 0 in the screen. i want to google this kind of usage, so i have to type these two symbol $? in the search blank.But the search engine just return nothing to me... i have looked at the google help page, but still can't find a solution. so my question is: how can i search with this kind of keyword. or if you can give me some advise of the usage of $? or sort of thing, that will be also appreciated.

    Read the article

1