Search Results

Search found 770 results on 31 pages for 'ar mailer'.

Page 5/31 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Applying the same function to each object of an array in objective-c

    - by sagar
    Hey ! every one. I am having some query regarding Objective-c. Let's have a look to following code. NSArray *ar=[scrPDFPage subviews]; int i; for (i=0; i<[ar count]; i++) { [(UIView*)[ar objectAtIndex:i] removeFromSuperview]; } now my queries are as follows, Instead of rotating a loop, isn't there an option like, [ar applyFunctionToObjects:@selector(myFunction:)] Isn't there any option like [myView removeAllSubViews]; ( According to my knowledge, there is no option like remove all sub views, but in case you might know. ) Thanks in advance for sharing your knowledge. Sagar.

    Read the article

  • Compiler optimization of repeated accessor calls

    - by apocalypse9
    I've found recently that for some types of financial calculations that the following pattern is much easier to follow and test especially in situations where we may need to get numbers from various stages of the computation. public class nonsensical_calculator { ... double _rate; int _term; int _days; double monthlyRate { get { return _rate / 12; }} public double days { get { return (1 - i); }} double ar { get { return (1+ days) /(monthlyRate * days) double bleh { get { return Math.Pow(ar - days, _term) public double raar { get { return bleh * ar/2 * ar / days; }} .... } Obviously this often results in multiple calls to the same accessor within a given formula. I was curious as to whether or not the compiler is smart enough to optimize away these repeated calls with no intervening change in state, or whether this style is causing a decent performance hit. Further reading suggestions are always appreciated

    Read the article

  • Compilier optimization of repeated accessor calls C#

    - by apocalypse9
    I've found recently that for some types of financial calculations that the following pattern is much easier to follow and test especially in situations where we may need to get numbers from various stages of the computation. public class nonsensical_calculator { ... double _rate; int _term; int _days; double monthlyRate { get { return _rate / 12; }} public double days { get { return (1 - i); }} double ar { get { return (1+ days) /(monthlyRate * days) double bleh { get { return Math.Pow(ar - days, _term) public double raar { get { return bleh * ar/2 * ar / days; }} .... } Obviously this often results in multiple calls to the same accessor within a given formula. I was curious as to whether or not the compiler is smart enough to optimize away these repeated calls with no intervening change in state, or whether this style is causing a decent performance hit. Further reading suggestions are always appreciated

    Read the article

  • Rails: Auto-Detecting Database Adapter

    - by Dex
    The new version of the ar-extensions gem requires that you load the appropriate adapter yourself. On my development side I use mysql, however Heroku uses PostgreSQL. For example, on my development side I need to do this: require 'ar-extensions/adapters/mysql' require 'ar-extensions/import/mysql' How can I audo-detect which adapter to use?

    Read the article

  • What -W values in gcc correspond to which actual warnings?

    - by SebastianK
    Preamble: I know, disabling warnings is not a good idea. Anyway, I have a technical question about this. Using GCC 3.3.6, I get the following warning: choosing ... over ... because conversion sequence for the argument is better. Now, I want to disable this warning as described in gcc warning options by providing an argument like -Wno-theNameOfTheWarning But I don't know the name of the warning. How can I find out the name of the option that disables this warning? I am not able to fix the warning, because it occurs in a header of an external library that can not be changed. It is in boost serialization (rx(s, count)): template<class Archive, class Container, class InputFunction, class R> inline void load_collection(Archive & ar, Container &s) { s.clear(); // retrieve number of elements collection_size_type count; unsigned int item_version; ar >> BOOST_SERIALIZATION_NVP(count); if(3 < ar.get_library_version()) ar >> BOOST_SERIALIZATION_NVP(item_version); else item_version = 0; R rx; rx(s, count); std::size_t c = count; InputFunction ifunc; while(c-- > 0){ ifunc(ar, s, item_version); } } I have already tried #pragma GCC system_header but this had no effect. Using -isystem instead of -I also does not work. The general question remains is: I know the text of the warning message. But I do not know the correlation to the gcc warning options.

    Read the article

  • In chrome with a greasemonkey extension, how can I modify an `<a...>` construct to strip out the onc

    - by Ross Rogers
    I want to modify an internal webpage to strip away some of the onclick behavior of certain links. The internal webpage has a bunch of links like: <a href="/slm/detail/ar/3116370" onclick="rallyPorthole.showDetail('/ar/view.sp','3116370','pj/b');return false;">foo de fa fa</a> How can I do an extension to Chrome so it does the following: for link in all_links: if link's href attribute matches '/slm/detail/ar/...': remove the onclick attribute

    Read the article

  • My server keeps sending emails to [email protected]

    - by xtrimsky
    When I type mailq on my server, I get: BB523653A62 4025 Wed Jun 4 10:40:07 MAILER-DAEMON (delivery temporarily suspended: host p3smtpout.secureserver.net[208.109.80.54] refused to talk to me: 554 p3plsmtpout002.prod.phx3.secureserver.net : DED : AJeb1o0334uf1Y801 : DED : You've reached your daily relay quota - IP.ADDRESS) [email protected] B33AD653A4A 4025 Wed Jun 4 08:20:07 MAILER-DAEMON (delivery temporarily suspended: host p3smtpout.secureserver.net[208.109.80.54] refused to talk to me: 554 p3plsmtpout002.prod.phx3.secureserver.net : DED : AJeb1o0334uf1Y801 : DED : You've reached your daily relay quota - IP.ADDRESS) [email protected] B77DF653A63 4025 Wed Jun 4 10:50:07 MAILER-DAEMON (delivery temporarily suspended: host p3smtpout.secureserver.net[208.109.80.54] refused to talk to me: 554 p3plsmtpout001.prod.phx3.secureserver.net : DED : AJvF1o00L4uf1Y801 : DED : You've reached your daily relay quota - IP.ADDRESS) [email protected] B943C653A3C 4025 Wed Jun 4 06:40:07 MAILER-DAEMON (delivery temporarily suspended: host p3smtpout.secureserver.net[208.109.80.54] refused to talk to me: 554 p3plsmtpout001.prod.phx3.secureserver.net : DED : AKBv1o00P4uf1Y801 : DED : You've reached your daily relay quota - IP.ADDRESS) [email protected] (there is probably about 50 of these, and I've cleared the queue today), do you know where these could be coming from ? is it my server sending some logs to "hostmaster" ? I've replaced my actual domain, with "MYDOMAIN". How can I find what could be sending these emails ? The server has recently been hacked so I'm also a bit worried. Thanks!

    Read the article

  • Extract object (*.o) files from an iPhone static library

    - by Brett
    I have a set of iPhone static libraries (a *.a file) in which I only call a few of the classes from. I have used AR in the past (with linux libraries) to extract the object files from the static library, remove the unwanted object files and rearchive. However, when I try this with an iPhone compliled static library, I get the following error: ar: CustomiPhoneLib.a is a fat file (use libtool(1) or lipo(1) and ar(1) on it) ar: CustomiPhoneLib.a: Inappropriate file type or format Does anyone know how to extract the object files from an iphone compiled static library? Doing thie could potentially reduce the final file size.

    Read the article

  • Rails 3 HABTM Strange Association: Project and Employee in a tree.

    - by Mauricio
    Hi guys I have to adapt an existing model to a new relation. I have this: A Project has many Employees. the Employees of a Project are organized in some kind of hierarchy (nothing fancy, I resolved this adding a parent_id for each employee to build the 'tree') class Employee < AR:Base belongs_to :project belongs_to :parent, :class_name => 'Employee' has_many :childs, :class_name => 'Employee', :foreign_column => 'parent_id' end class Project < AR:Base has_many :employees, end That worked like a charm, now the new requirement is: The Employees can belong to many Projects at the same time, and the hierarchy will be different according to the project. So I though I will need a new table to build the HABTM, and a new class to access the parent_id to build the tree. Something like class ProjectEmployee < AR:Base belongs_to :project belongs_to :employee belongs_to :parent, :class_name => 'Employee' # <--- ?????? end class Project < AR:Base has_many :project_employee has_many :employees, :through => :project_employee end class Employee < AR:Base has_many :project_employee has_many :projects, :through => :project_employee end How can I access the parent and the childs of an employee for a given project? I need to add and remove childs as wish from the employees of a project. Thank you!

    Read the article

  • How to coerce type of ActiveRecord attribute returned by :select phrase on joined table?

    - by tribalvibes
    Having trouble with AR 2.3.5, e.g.: users = User.all( :select => "u.id, c.user_id", :from => "users u, connections c", :conditions => ... ) Returns, e.g.: => [#<User id: 1000>] >> users.first.attributes => {"id"=>1000, "user_id"=>"1000"} Note that AR returns the id of the model searched as numeric but the selected user_id of the joined model as a String, although both are int(11) in the database schema. How could I better form this type of query to select columns of tables backing multiple models and retrieving their natural type rather than String ? Seems like AR is punting on this somewhere. How could I coerce the returned types at AR load time and not have to tack .to_i (etc.) onto every post-hoc access?

    Read the article

  • How to get exactly typeof is object/array/null..?

    - by 3gwebtrain
    var obj = {},ar = [],nothing=null,empty=undefined,word ='string',headorTail = true; console.log(typeof obj) //object console.log(typeof ar)//object console.log(typeof nothing)//object console.log(typeof empty)//undefined console.log(typeof word)//string console.log(typeof headorTail)//boolean But how can i get the type of obj,ar,nothing as "object, array,null" - what is the best way to achieve this?

    Read the article

  • I need a js function that can sort state from Dropbox and gave me a phone number to call [on hold]

    - by User584
    AL West AR West CT EAST DC EAST Il West MN East player one groupe A player tow Groupe B player zero Groupe D if the Group is A and the State is AL then Phone = 0762154852 if the Group is B and the State is AR then phone = 2145632541 if the group is D and the state is MN then phone = 2589632541 if i player from a dropbox and then i select State from a dropbox I want the Field phone Show the right number

    Read the article

  • Server being used to send spam mail. How do I investigate?

    - by split_account
    Problem I think my server is being used to send spam with sendmail, I'm getting a lot of mail being queued up that I don't recognize and my mail.log and syslog are getting huge. I've shutdown sendmail, so none of it is getting out but I can't work out where it's coming from. Investigation so far: I've tried the solution in the blog post below and also shown in this thread. It's meant to add a header from wherever the mail is being added and log all all mail to file, so I changed the following lines in my php.ini file: mail.add_x_header = On mail.log = /var/log/phpmail.log But nothing is appearing in the phpmail.log. I used the command here to investigate cron jobs for all users, but nothing is out of place. The only cron being run is the cron for the website. And then I brought up all php files which had been modified in the last 30 days but none of them look suspicious. What else can I do to find where this is coming from? Mail.log reports Turned sendmail back on for second. Here is a small sample of the reports: Jun 10 14:40:30 ubuntu12 sm-mta[13684]: s5ADeQdp013684: from=<>, size=2431, class=0, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1] Jun 10 14:40:30 ubuntu12 sm-msp-queue[13674]: s5ACK1cC011438: to=www-data, delay=01:20:14, xdelay=00:00:00, mailer=relay, pri=571670, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (s5ADeQdp013684 Message accepted for delivery) Jun 10 14:40:30 ubuntu12 sm-mta[13719]: s5ADeQdp013684: to=<[email protected]>, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=32683, dsn=2.0.0, stat=Sent Jun 10 14:40:30 ubuntu12 sm-mta[13684]: s5ADeQdr013684: from=<[email protected]>, size=677, class=0, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1] Jun 10 14:40:31 ubuntu12 sm-msp-queue[13674]: s5AC0gpi011125: to=www-data, ctladdr=www-data (33/33), delay=01:39:49, xdelay=00:00:01, mailer=relay, pri=660349, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (s5ADeQdr013684 Message accepted for delivery) Jun 10 14:40:31 ubuntu12 sm-mta[13721]: s5ADeQdr013684: to=<[email protected]>, ctladdr=<[email protected]> (33/33), delay=00:00:01, xdelay=00:00:00, mailer=local, pri=30946, dsn=2.0.0, stat=Sent Jun 10 14:40:31 ubuntu12 sm-mta[13684]: s5ADeQdt013684: from=<[email protected]>, size=677, class=0, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1] Jun 10 14:40:31 ubuntu12 sm-msp-queue[13674]: s5ACF2Nq011240: to=www-data, ctladdr=www-data (33/33), delay=01:25:29, xdelay=00:00:00, mailer=relay, pri=660349, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (s5ADeQdt013684 Message accepted for delivery) Jun 10 14:40:31 ubuntu12 sm-mta[13723]: s5ADeQdt013684: to=<[email protected]>, ctladdr=<[email protected]> (33/33), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=30946, dsn=2.0.0, stat=Sent Ju Further Investigation Spotted 4 spam accounts registered in the past day, which is suspicious however all have normal user privileges. There are no contact forms on the site, there are a number of forms and they take either filtered text input or plain text input. Mail is still being queued up having switched the website to maintenance mode, which blocks out everyone but the admin. Ok more investigation, it looks like the email is being send by my websites cron which runs every 5 minutes. However there are no cron jobs I've set-up which run more than once an hour and show on the website log so presumably someone has managed to edit my cron somehow. Copy of email: V8 T1402410301 K1402411201 N2 P120349 I253/1/369045 MDeferred: Connection refused by [127.0.0.1] Fbs $_www-data@localhost ${daemon_flags}c u Swww-data [email protected] MDeferred: Connection refused by [127.0.0.1] C:www-data rRFC822; [email protected] RPFD:www-data H?P?Return-Path: <?g> H??Received: (from www-data@localhost) by ubuntu12.pcsmarthosting.co.uk (8.14.4/8.14.4/Submit) id s5AEP13T015507 for www-data; Tue, 10 Jun 2014 15:25:01 +0100 H?D?Date: Tue, 10 Jun 2014 15:25:01 +0100 H?x?Full-Name: CronDaemon H?M?Message-Id: <[email protected]> H??From: root (Cron Daemon) H??To: www-data H??Subject: Cron <www-data@ubuntu12> /usr/bin/drush @main elysia-cron H??Content-Type: text/plain; charset=ANSI_X3.4-1968 H??X-Cron-Env: <PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin> H??X-Cron-Env: <COLUMNS=80> H??X-Cron-Env: <SHELL=/bin/sh> H??X-Cron-Env: <HOME=/var/www> H??X-Cron-Env: <LOGNAME=www-data>

    Read the article

  • Installing Windows 8 over Windows 7 with Ubuntu installed using wubi (both on `C:\`)

    - by peat-ar
    Current state I'm using both - Ubuntu (installed via Wubi on the same drive as Windows) and Windows 7 - quite frequently. I just bought the upgrade to Windows 8 and was curious to try it out, however I'm quite insecure whether Windows 8's "secure boot" will exclude my current Ubuntu installation and if it's even possible to keep it. So... is there any way to upgrade to Windows 8 without overwriting Ubuntu? (I really don't want to reinstall it, as a lot of customization has been done here and taking backups and all would get pretty wearing (same case for Windows 7 - if possible, I'd like to keep my files)) This is not a dublicate of Installing Windows 8 over Windows 7 with Ubuntu installed using wubi? because this question only deals with the case when Ubuntu has been installed on (e.g.) D:\ (while Windows is being installed on C:\)

    Read the article

  • Compiling GCC or Clang for thumb drive on OSX

    - by user105524
    I have a mac book that I don't have admin rights to which I would like to be able to use either GCC or clang. Since I lack admin right I can't install binutils or a compiler to /usr directory. My plan is to install both of these (using an old macbook that I do have admin rights for) to a flash drive and then run the compiler off of there. How would one go building gcc or clang so that it could run just off of a thumb drive? I've tried both but haven't had any success. I've tried doing it defining as many of the directories as possible through configure, but haven't been able to successfully build. My current configure script for gcc-4.8.1 is (where USB20D is the thumb drive): ../gcc-4.8.1/configure --prefix=/Volumes/USB20FD/usr \ --with-local-prefix=/Volumes/USB20FD/usr/local \ --with-native-system-header-dir=/Volumes/USB20FD/usr/include \ --with-as=/Volumes/USB20FD/usr/bin/as \ --enable-languages=c,c++,fortran\ --with-ld=/Volumes/USB20FD/usr/bin/ld \ --with-build-time-tools=/Volumes/USB20FD/usr/bin \ AR=/Volumes/USB20FD/usr/bin/ar \ AS=/Volumes/USB20FD/usr/bin/as \ RANLIB=/Volumes/USB20FD/usr/bin/ranlib \ LD=/Volumes/USB20FD/usr/bin/ld \ NM=/Volumes/USB20FD/usr/bin/nm \ LIPO=/Volumes/USB20FD/usr/bin/lipo \ AR_FOR_TARGET=/Volumes/USB20FD/usr/bin/ar \ AS_FOR_TARGET=/Volumes/USB20FD/usr/bin/as \ RANLIB_FOR_TARGET=/Volumes/USB20FD/usr/bin/ranlib \ LD_FOR_TARGET=/Volumes/USB20FD/usr/bin/ld \ NM_FOR_TARGET=/Volumes/USB20FD/usr/bin/nm \ LIPO_FOR_TARGET=/Volumes/USB20FD/usr/bin/lipo CFLAGS=" -nodefaultlibs -nostdlib -B/Volumes/USB20FD/bin -isystem/Volumes/USB20FD/usr/include -static-libgcc -v -L/Volumes/USB20FD/usr/lib " \ LDFLAGS=" -Z -lc -nodefaultlibs -nostdlib -L/Volumes/USB20FD/usr/lib -lgcc -syslibroot /Volumes/USB20FD/usr/lib/crt1.10.6.o " Any obvious ideas of which of these options need to be turned on to install the appropriate files on the thumb drive during installation? What other magic occurs during xcode installation which isn't occurring here? Thanks for any suggestions

    Read the article

  • How to pass user-defined structs using boost mpi

    - by lava
    I am trying to send a user-defined structure named ABC using boost::mpi::send () call. The given struct contains a vector "data" whose size is determined at runtime. Objects of struct ABC are sent by master to slaves. But the slaves need to know the size of vector "data" so that the sufficient buffer is available on the slave to receive this data. I can work around it by sending the size first and initialize sufficient buffer on the slave before receiving the objects of struct ABC. But that defeats the whole purpose of using STL containers. Does anyone know of a better way to do handle this ? Any suggestions are greatly appreciated. Here is a sample code that describes the intent of my program. This code fails at runtime due to above mentioned reason. struct ABC { double cur_stock_price; double strike_price; double risk_free_rate; double option_price; std::vector <char> data; }; namespace boost { namespace serialization { template<class Archive> void serialize (Archive &ar, struct ABC &abc, unsigned int version) { ar & abc.cur_stock_price; ar & abc.strike_price; ar & abc.risk_free_rate; ar & abc.option_price; ar & bopr.data; } } } BOOST_IS_MPI_DATATYPE (ABC); int main(int argc, char* argv[]) { mpi::environment env (argc, argv); mpi::communicator world; if (world.rank () == 0) { ABC abc_obj; abc.cur_stock_price = 1.0; abc.strike_price = 5.0; abc.risk_free_rate = 2.5; abc.option_price = 3.0; abc_obj.data.push_back ('a'); abc_obj.data.push_back ('b'); world.send ( 1, ANY_TAG, abc_obj;); std::cout << "Rank 0 OK!" << std::endl; } else if (world.rank () == 1) { ABC abc_obj; // Fails here because abc_obj is not big enough world.recv (0,ANY_TAG, abc_obj;); std::cout << "Rank 1 OK!" << std::endl; for (int i = 0; i < abc_obj;.data.size(); i++) std::cout << i << "=" << abc_obj.data[i] << std::endl; } MPI_Finalize(); return 0; }

    Read the article

  • How do I permanently delete e-mail messages in the sendmail queue and keep them from coming back?

    - by Steven Oxley
    I have a pretty annoying problem here. I have been testing an application and have created some test e-mails to bogus e-mail addresses (not to mention that my server isn't really set up to send e-mail anyway). Of course, sendmail is not able to send these messages and they have been getting stuck in the sendmail queue. I want to manually delete the messages that have been building up in the queue instead of waiting the 5 days that sendmail usually takes to stop retrying. I am using Ubuntu 10.04 and /var/spool/mqueue/ is the directory in which every how-to I have read says the e-mails that are queued up are kept. When I delete the files in this directory, sendmail stops trying to process the e-mails until what appears to be a cron script runs and re-populates this directory with the messages I don't want sent. Here are some lines from my syslog: Jun 2 17:35:19 sajo-laptop sm-mta[9367]: o530SlbK009365: to=, ctladdr= (33/33), delay=00:06:27, xdelay=00:06:22, mailer=esmtp, pri=120418, relay=e.mx.mail.yahoo.com. [67.195.168.230], dsn=4.0.0, stat=Deferred: Connection timed out with e.mx.mail.yahoo.com. Jun 2 17:35:48 sajo-laptop sm-mta[9149]: o4VHn3cw003597: to=, ctladdr= (33/33), delay=2+06:46:45, xdelay=00:34:12, mailer=esmtp, pri=3540649, relay=mx2.hotmail.com. [65.54.188.94], dsn=4.0.0, stat=Deferred: Connection timed out with mx2.hotmail.com. Jun 2 17:39:02 sajo-laptop CRON[9510]: (root) CMD ( [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -type f -cmin +$(/usr/lib/php5/maxlifetime) -print0 | xargs -n 200 -r -0 rm) Jun 2 17:39:43 sajo-laptop sm-mta[9372]: o52LHK4s007585: to=, ctladdr= (33/33), delay=03:22:18, xdelay=00:06:28, mailer=esmtp, pri=1470404, relay=c.mx.mail.yahoo.com. [206.190.54.127], dsn=4.0.0, stat=Deferred: Connection timed out with c.mx.mail.yahoo.com. Jun 2 17:39:50 sajo-laptop sm-mta[9149]: o51I8ieV004377: to=, ctladdr= (33/33), delay=1+06:31:06, xdelay=00:03:57, mailer=esmtp, pri=6601668, relay=alt4.gmail-smtp-in.l.google.com. [74.125.79.114], dsn=4.0.0, stat=Deferred: Connection timed out with alt4.gmail-smtp-in.l.google.com. Jun 2 17:40:01 sajo-laptop CRON[9523]: (smmsp) CMD (test -x /etc/init.d/sendmail && /usr/share/sendmail/sendmail cron-msp) Does anyone know how I can get rid of these messages permanently? As a side note, I'd also like to know if there is a way to set up sendmail to "fake" sending e-mail. Is there?

    Read the article

  • how can we use AsynCallback method of web service in asp.net

    - by sameer
    Hi All, I was going through the proxy class which is generated using wsdl.exe found the asyncmethod like BeginAsynXXX() and EndAsyncXXX(). i understood how to utilize them on Windows application but i was wondering how can we use them in Web Application built using asp.net here is the code for web service client build as windows application.can any tell me how we can do this with web application. using System; using System.Runtime.Remoting.Messaging; using MyFactorize; class TestCallback { public static void Main(){ long factorizableNum = 12345; PrimeFactorizer pf = new PrimeFactorizer(); //Instantiate an AsyncCallback delegate to use as a parameter //in the BeginFactorize method. AsyncCallback cb = new AsyncCallback(TestCallback.FactorizeCallback); // Begin the Async call to Factorize, passing in our // AsyncCalback delegate and a reference // to our instance of PrimeFactorizer. IAsyncResult ar = pf.BeginFactorize(factorizableNum, cb, pf); // Keep track of the time it takes to complete the async call // as the call proceeds. int start = DateTime.Now.Second; int currentSecond = start; while (ar.IsCompleted == false){ if (currentSecond < DateTime.Now.Second) { currentSecond = DateTime.Now.Second; Console.WriteLine("Seconds Elapsed..." + (currentSecond - start).ToString() ); } } // Once the call has completed, you need a method to ensure the // thread executing this Main function // doesn't complete prior to the call-back function completing. Console.Write("Press Enter to quit"); int quitchar = Console.Read(); } // Set up a call-back function that is invoked by the proxy class // when the asynchronous operation completes. public static void FactorizeCallback(IAsyncResult ar) { // You passed in our instance of PrimeFactorizer in the third // parameter to BeginFactorize, which is accessible in the // AsyncState property. PrimeFactorizer pf = (PrimeFactorizer) ar.AsyncState; long[] results; // Get the completed results. results = pf.EndFactorize(ar); //Output the results. Console.Write("12345 factors into: "); int j; for (j = 0; j<results.Length;j++){ if (j == results.Length - 1) Console.WriteLine(results[j]); else Console.Write(results[j] + ", "); } } }

    Read the article

  • WPF windows locked when calling webservice. Even when run asynchronously

    - by SumGuy
    Hi there. I'm having a big problem when calling a web service from my WPF application. The application/window locks until the process has completed. I've attempted to run this asynchronously but the problem still persists. Currently, the web service call I'm making can last 45-60 seconds. It runs a process on the server to fetch a big chunk of data. As it take a little while I wanted to have a progress bar moving indeterminately for the user to see that the application hasn't stalled or anything (you know how impatatient they get). So: private void btnSelect_Click(object sender, RoutedEventArgs e) { wDrawingList = new WindowDrawingList(systemManager); AsyncMethodHandler caller = default(AsyncMethodHandler); caller = new AsyncMethodHandler(setupDrawingList); // open new thread with callback method caller.BeginInvoke((Guid)((Button)sender).Tag, MyAsyncCallback, null); } Click a button and the app will create the form that the async stuff will be posted to and set up the async stuff calling the async method. public bool setupDrawingList(Guid ID) { if (systemManager.set(ID)) { wDrawingList.Dispatcher.Invoke(DispatcherPriority.Background, new Action(() => { wDrawingList.ShowForm(); Hide(); })); return true; } return false; } This is the async method. The showForm method contains the calls to setup the new form including the monster web service call public void MyAsyncCallback(IAsyncResult ar) { // Because you passed your original delegate in the asyncState parameter of the Begin call, you can get it back here to complete the call. MethodDelegate dlgt = (MethodDelegate)ar.AsyncState; // Complete the call. bool output = dlgt.EndInvoke(ar); try { // Retrieve the delegate. AsyncResult result = (AsyncResult)ar; AsyncMethodHandler caller = (AsyncMethodHandler)result.AsyncDelegate; // Because this method is running from secondary thread it can never access ui objects because they are created // on the primary thread. // Call EndInvoke to retrieve the results. bool returnValue = caller.EndInvoke(ar); // Still on secondary thread, must update ui on primary thread UpdateUI(returnValue == true ? "Success" : "Failed"); } catch (Exception ex) { string exMessage = null; exMessage = "Error: " + ex.Message; UpdateUI(exMessage); } } public void UpdateUI(string outputValue) { // Get back to primary thread to update ui UpdateUIHandler uiHandler = new UpdateUIHandler(UpdateUIIndicators); string results = outputValue; // Run new thread off Dispatched (primary thread) this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, uiHandler, results); } public void UpdateUIIndicators(string outputValue) { // update user interface controls from primary UI thread sbi3.Content = "Processing Completed."; } Any help or theories are appreciated. I'm at a loss. Thanks in advance

    Read the article

  • UDP Tracker not responding

    - by kelton52
    Alright, so I'm trying to connect to UDP trackers using c#, but I never get a response. I also don't get any errors. Here's my code. namespace UDPTester { class MainClass { public static bool messageReceived = false; public static Random Random = new Random(); public static void LOG(string format, params object[] args) { Console.WriteLine (format,args); } public static void Main (string[] args) { LOG ("Creating Packet..."); byte[] packet; using(var stream = new MemoryStream()) { var bc = new MiscUtil.Conversion.BigEndianBitConverter(); using(var br = new MiscUtil.IO.EndianBinaryWriter(bc,stream)) { LOG ("Magic Num: {0}",(Int64)0x41727101980); br.Write (0x41727101980); br.Write((Int32)0); br.Write ((Int32)Random.Next()); packet = stream.ToArray(); LOG ("Packet Size: {0}",packet.Length); } } LOG ("Connecting to tracker..."); var client = new System.Net.Sockets.UdpClient("tracker.openbittorrent.com",80); UdpState s = new UdpState(); s.e = client.Client.RemoteEndPoint; s.u = client; StartReceiving(s); LOG ("Sending Packet..."); client.Send(packet,packet.Length); while(!messageReceived) { Thread.Sleep(1000); } LOG ("Ended"); } public static void StartReceiving(UdpState state) { state.u.BeginReceive(ReceiveCallback,state); } public static void ReceiveCallback(IAsyncResult ar) { UdpClient u = (UdpClient)((UdpState)(ar.AsyncState)).u; IPEndPoint e = (IPEndPoint)((UdpState)(ar.AsyncState)).e; Byte[] receiveBytes = u.EndReceive(ar, ref e); string receiveString = Encoding.ASCII.GetString(receiveBytes); LOG("Received: {0}", receiveString); messageReceived = true; StartReceiving((UdpState)ar.AsyncState); } } public class UdpState { public UdpClient u; public EndPoint e; } } I was using a normal BinaryWriter, but that didn't work, and I read somewhere that it wants it's data in BigEndian. This doesn't work for any of the UDP trackers I've found, any ideas why I'm not getting a response? Did they maybe change the protocol and not tell anyone? HTTP trackers all work fine. Trackers I've tried udp://tracker.publicbt.com:80 udp://tracker.ccc.de:80 udp://tracker.istole.it:80 Also, I'm not interested in using MonoTorrent(and when I was using it, the UDP didn't work anyways). Protocol Sources http://xbtt.sourceforge.net/udp_tracker_protocol.html http://www.rasterbar.com/products/libtorrent/udp_tracker_protocol.html

    Read the article

  • Customize the From address in Rails application

    - by palani
    Hi , I have mailer action in my application, the mailer is configured with gmail smtp. The following is my config details under environment.rb file require "smtp_tls" ActionMailer::Base.delivery_method = :smtp ActionMailer::Base.perform_deliveries = true ActionMailer::Base.raise_delivery_errors = true ActionMailer::Base.default_charset = "utf-8" ActionMailer::Base.default_content_type = "text/html" ActionMailer::Base.smtp_settings = { :address => "smtp.gmail.com", :port => 587, :domain => 'gmail.com', :user_name => "[email protected]", :password => "password", :authentication => :plain The think i want to implement is, when ever the application generating email the from address shows "[email protected]". Is possible to customize the from address. In different places i want to use different From address instead of "[email protected]" I tried with my mailer model: @from = "#{user.email}" In development server log it shows the customized id correctly. if go my email inbox it shows the from address as "[email protected]" Can any one please guide on this. thanks in advance.

    Read the article

  • WPF Styles and Tooltips Question

    - by A.R.
    I have a style that I am using to make dynamic tooltips on certain text boxes like so. <Style TargetType="{x:Type TextBox}"> <Setter Property="MinWidth" Value="100"/> <Style.Triggers> <Trigger Property="Validation.HasError" Value="True"> <!-- item of interest --> <Setter Property="ToolTip"> <Setter.Value> <MultiBinding Converter="{StaticResource ErrorMessageConverter}"> <Binding RelativeSource="{RelativeSource Self}" Path="Tag"/> </MultiBinding> </Setter.Value> </Setter> </Trigger> </Style.Triggers> </Style> This works very well, but if I want to use a more complex tooltip I can't figure out how to bind to 'Tag' anymore for the converter value. For example; ... <Setter Property="ToolTip"> <Setter.Value> <StackPanel> <TextBlock> <TextBlock.Text> <MultiBinding Converter="{StaticResource ErrorMessageConverter}"> <!-- item of interest --> <Binding RelativeSource=" what goes here?? "/> </MultiBinding> </TextBlock.Text> </TextBlock> <Image/> </StackPanel> </Setter.Value> </Setter> ... I have tried several flavors of 'FindAncestor' and what not for the relative source, but I can't get anything to work. Any ideas?? UPDATE: 12-29-2010 : Here is the correct code, answer provided by our friend Goblin below. Works perfectly! ... <Setter Property="ToolTip"> <Setter.Value> <!-- Item of interest --> <ToolTip DataContext="{Binding Path=PlacementTarget, RelativeSource={x:Static RelativeSource.Self}}"> <StackPanel> <Image/> <TextBlock> <TextBlock.Text> <MultiBinding Converter="{StaticResource ErrorMessageConverter}"> <Binding Path="Tag"/> </MultiBinding> </TextBlock.Text> </TextBlock> </StackPanel> </ToolTip> </Setter.Value> </Setter> ...

    Read the article

  • Understanding Haskell's fibonacci

    - by AR
    fibs :: [Int] fibs = 0 : 1 : [ a + b | (a, b) <- zip fibs (tail fibs)] This generates the Fibonacci sequence. I understand the behaviour of the guards, of :, zip and tail, but I don't understand <-. What is it doing here?

    Read the article

  • Cannot convert IAsyncResult to AsyncResult when using a service refrence

    - by Scott Chamberlain
    I have a WCF service running, I added a reference to the service by using Add Service Reference in the solution explorer, and I checked the box for create asynchronous operations. My call works fine, I have a two way channel that reports back some events from the server and I am receiving the events. However, when the asynchronous task finishes in my callback handeler I get the error Unable to cast object of type 'SendAsyncResult' to type 'System.Runtime.Remoting.Messaging.AsyncResult'. Code that calls the method. DatabaseManagement.DatabaseManagementClient d = new DatabaseManagement.DatabaseManagementClient(new InstanceContext(new DatabaseManagementCallback())); d.Open(); d.BeginCreateDatabase("", "PreConfSA", "_test", new AsyncCallback(BeginCreateDatabaseCallback), null); The Async callback static void BeginCreateDatabaseCallback(IAsyncResult ar) { AsyncResult result = (AsyncResult)ar; //Execption happens here DatabaseManagement.DatabaseManagementClient caller = (DatabaseManagement.DatabaseManagementClient)result.AsyncDelegate; Console.WriteLine(caller.EndCreateDatabase(ar)); //Do more stuff here } Execption Details System.InvalidCastException was unhandled by user code Message=Unable to cast object of type 'SendAsyncResult' to type 'System.Runtime.Remoting.Messaging.AsyncResult'. Source=Sandbox Console StackTrace: at Sandbox_Console.Program.BeginCreateDatabaseCallback(IAsyncResult ar) in E:\Visual Studio 2010\Projects\Sandbox Console\Program.cs:line 26 at System.ServiceModel.AsyncResult.Complete(Boolean completedSynchronously) InnerException: I don't really need the result from the EndCreateDatabase but everywhere I read it says that you must call EndYouFunctionHere() or bad things happen. Any recomendations?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >