{"id":896,"date":"2009-08-04T12:57:23","date_gmt":"2009-08-04T11:57:23","guid":{"rendered":"http:\/\/soci.hu\/blog\/?p=896"},"modified":"2009-08-04T12:58:07","modified_gmt":"2009-08-04T11:58:07","slug":"a-jitter-huncutsagai","status":"publish","type":"post","link":"https:\/\/soci.hu\/blog\/index.php\/2009\/08\/04\/a-jitter-huncutsagai\/","title":{"rendered":"A jitter huncuts\u00e1gai"},"content":{"rendered":"<p>\u00c9rdekes \u00e9s furcsa dolgok t\u00f6rt\u00e9nnek n\u00e9ha a .net jitter miatt, ami nem nagyon fordul el\u0151 nem managelt k\u00f6rnyezetben.<\/p>\n<p>Itt ez a kis factoryka r\u00e9szlet:<\/p>\n<p>public IBroker GetBroker()<br \/>\n{<br \/>\n    if (broker == null)<br \/>\n    {<br \/>\n        switch (BrokerMode)<br \/>\n        {<br \/>\n            case BrokerMode.Simulated:<br \/>\n                broker = new BrokerSimulated();<br \/>\n                break;<br \/>\n            case BrokerMode.IB:<br \/>\n                broker = IBBroker.Instance;<br \/>\n                break;<br \/>\n        }<br \/>\n    }<br \/>\n    return broker;<br \/>\n}<\/p>\n<p>Amikor megh\u00edvtam ezt a sort:<\/p>\n<p>BrokerFactory.Factory.GetBroker().SetInitialEquity(20000);<\/p>\n<p>akkor furcsam\u00f3d lefutott az \u00e9l\u0151 broker, az IBBroker konstruktora. Pedig NEM az az \u00e1g futott le a switchben. Val\u00f3sz\u00edn\u0171leg az t\u00f6rt\u00e9nt, hogy a jitter hozz\u00e1\u00e9rt az IBBroker oszt\u00e1lyhoz, ez pedig t\u00f6rv\u00e9nyszer\u0171en kiv\u00e1ltotta a statikus konstruktor lefut\u00e1s\u00e1t.<\/p>\n<p>A megold\u00e1s pofonegyszer\u0171 (ha ismerj\u00fck az okot :), ki kell emelni a beteg t\u00edpusra hivatkoz\u00e1st egy k\u00fcl\u00f6n met\u00f3dusba. Mivel a jitter met\u00f3dusonk\u00e9nt dolgozik, \u00edgy addig t\u00e9nyleg nem ny\u00fal a t\u00edpusunkhoz, m\u00edg t\u00e9nyleg nem haszn\u00e1ljuk:<\/p>\n<p>public IBroker GetBroker()<br \/>\n{<br \/>\n    if (broker == null)<br \/>\n    {<br \/>\n        switch (BrokerMode)<br \/>\n        {<br \/>\n            case BrokerMode.Simulated:<br \/>\n                broker = new BrokerSimulated();<br \/>\n                break;<br \/>\n            case BrokerMode.IB:<br \/>\n                broker = CreateIBBroker();<br \/>\n                break;<br \/>\n        }<br \/>\n    }<br \/>\n    return broker;<br \/>\n}<\/p>\n<p>private static IBBroker CreateIBBroker()<br \/>\n{<br \/>\n    return IBBroker.Instance;<br \/>\n}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u00c9rdekes \u00e9s furcsa dolgok t\u00f6rt\u00e9nnek n\u00e9ha a .net jitter miatt, ami nem nagyon fordul el\u0151 nem managelt k\u00f6rnyezetben. Itt ez a kis&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,10,11,4],"tags":[],"class_list":["post-896","post","type-post","status-publish","format-standard","hentry","category-net","category-c","category-clr","category-szakmai-elet"],"_links":{"self":[{"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/posts\/896","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=896"}],"version-history":[{"count":2,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/posts\/896\/revisions"}],"predecessor-version":[{"id":898,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/posts\/896\/revisions\/898"}],"wp:attachment":[{"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=896"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=896"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=896"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}