Cocoa Windows Rectangle warning

Leave a comment

  • Issue descriptions : http://stackoverflow.com/questions/1797857/apple-interface-builder-warning-this-windows-content-rectangle-dows-not-lie-enti
  • Solution : for windows position of application, if there is no default position, cocoa framework runtime will run by default, However, the building framework will give warning.

Other available software for screen-shot : http://www.mac52ipod.cn/post/CaptureMe-Skitch-Jing.php

  • If video driver has some issues[for instance, on virtualbox system, it mayn’t save correctly on the desktop]
Advertisements

VSTemplate&MSBuild Category

Leave a comment

Unload VSPackage Project, then add MSBuild XML setting: http://msdn.microsoft.com/en-us/library/5dy88c2e.aspx

<!– To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name=”BeforeBuild”>
</Target>
–>
<Target Name=”AfterBuild”>
<ItemGroup>
<!– Mashup and WebService of Authoring Category, Orlando, 2011-08-18 –>
<AuthoringZipItemFilesToCopy Include=”.\$(BaseIntermediateOutputPath)$(Configuration)\HtmlMashupAuthoring.zip” />
</ItemGroup>
<Message Text=”Copying Zip Files to runtime folder”>
</Message>
<!– Mashup and WebService of Authoring, Orlando, 2011-08-18 –>
<Copy SourceFiles=”@(AuthoringZipItemFilesToCopy)” DestinationFolder=”..\$(Configuration)\Templates\ItemTemplates\MashupWebService Authoring” SkipUnchangedFiles=”true”>
</Copy>
</Target>
<Import Project=”$(MSBuildExtensionsPath)\Microsoft\VisualStudio\DSLTools\v10.0\Microsoft.DSLTools.targets” />
</Project>

Refer to :

ToString() with Parameter and Parse/TryParse with parameters

Leave a comment

When using object.ToString(), or <primitive>.Parse(), TryParse(), any more ideas?

Ya… Es ist…

  1. Which language and Culture are you handling with?
  2. Do you want to format via IFormattable interface or parsing it?

MSDN Link :

  •   Help View Home/Visual Studio 2010/.Net Framework 4/.Net Framework Core Development/Working with Base Type/Formatting Types or Parsing Strings [strongly recommend]
  •   CLR via C# Version 3, Jeffery Richter – Page 309

Just shared with you the code.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Globalization;

namespace _14_Strings
{
class Program
{
/// <summary>
/// Static method for formatting of Deutsch string -> Help View Home/Visual Studio 2010/.Net Framework 4/.Net Framework Core Development/Working with Base Type/Formatting Types or Parsing Strings
/// Jeffery Richter – Page 309
/// </summary>
static void IFormatProviderTest()
{
//foreach (CultureInfo item in System.Globalization.CultureInfo.GetCultures(CultureTypes.AllCultures)) //CultureTypes Enumeration
//{
//    Trace.WriteLine(item.ToString());
//}
decimal lNumericBase = 10000000L;//Int64->long
Trace.WriteLine(lNumericBase.ToString(“C”, new CultureInfo(“de-DE”)));
//Trace.WriteLine(lNumericBase.ToString(“D”, new CultureInfo(“de-DE”))); //Invalid format
Trace.WriteLine(lNumericBase.ToString(“N”, new CultureInfo(“de-DE”)));
string strNumericBase = lNumericBase.ToString(“N”, new CultureInfo(“de-DE”));

long number;
IFormatProvider provider = CultureInfo.CreateSpecificCulture(“de-DE”);

if (long.TryParse(strNumericBase, NumberStyles.AllowThousands | NumberStyles.AllowDecimalPoint, //NumberStyles.Number -> Group NumberStyles Enumeration
provider, out number))
{
Trace.WriteLine(number);
}

strNumericBase = lNumericBase.ToString(“N”, new CultureInfo(“de-DE”));
if (long.TryParse(strNumericBase, NumberStyles.AllowThousands | NumberStyles.AllowDecimalPoint, //NumberStyles.Number -> Group NumberStyles Enumeration
provider, out number))
{
Trace.WriteLine(number);
}
}

static void Main(string[] args)
{
Program.IFormatProviderTest();
}
}
}

Comparison in Run-time:


Html5+JS = Next Web?

Leave a comment

http://www.zdnet.com/blog/microsoft/microsoft-to-focus-on-html5-and-javascript-for-office-15-extensions/10266

Of couse, when Google adapted AJAX+JS framework to their gmail product, guys may still think “Yeah, it’s just a small change”.

When Google added SPDY[http://www.chromium.org/spdy] procotol into their implementation of Chrome,

guys may say “yeah, faster, as multi-Scream based on TCP ‘link'”.

But when we talked about html5, who can say “hi, I don’t want  to be in the game”.

Turning back to the news linked at the first line of essay, Now Microsoft followed the way of Google’s way for their Office via HTML5+JS.

Saying the world is changing now, slowly but incredibly[?]. ^_^

Trying to do something, hmmm…, I went through the “Professinal html5 programming” early of this year.

Except the mature framework supports, almost the thing is ready. [Sure, compared with WPF, a long way to go, however, comparsion between Web thing and naive local thing, infair.]

  • Checking up with IBM’s Maqetta – http://maqetta.org/. After taking a glance at it, VC of SAP ByD? [just a joking, two different things]
  • I like javascripts programming via Edit/Gedit, but where is the framework for HTML5? How does it looks like? ….

PS: Sliverlight5 => Where do you want to go, questions for Microsoft? I believe it still will be valuable, in case that Microsoft guys could define the clear scope for it. Difficult, but actually meaningful. Or….

 

 

C# STA Thread “Message Loop”

Leave a comment

seems a little bit impression, what’s the hell of Thread Message Loop.

  • Use Case – we have a STA DLL, which is exposed for us several COM/COM+ methods. And internally such DLL will store internal “status” cache, for instance STA instance, SA&G.
  • Key Points
  1. Explicit STA Thread construction – Thread.setApartment(STA/MTA). MTA is default setting.
  2. Supposed we call start(), and stop() for default instantiation logic of DLL, how about additional method called inside thread? Can we? Yes, just do something like Message loop. When performance has been concerned, EventWaitHandle (Mutex, Sep. etc)….

public class MethodProxyInThread
{
public MethodProxyInThread _realProxy;

private bool _isRealProxyStop = false;

private event EventHandler<EventArgs> _eventHandler;

private ThreadLocal<EventHandler<EventArgs>> _handler;

private Func<object, int> _functionalHook;

private EventWaitHandle waitHandle;

private object parameter;

/// <summary>
/// in one thread context
/// </summary>
/// <param name=”_realProxy”></param>
public void startMethod(object _realProxy)
{
if (this._realProxy == null)
{
this._realProxy = _realProxy as MethodProxyInThread;
this._isRealProxyStop = false;
Console.WriteLine(string.Format(“startMethod – {0}”, Thread.CurrentThread.ManagedThreadId));
Console.WriteLine(“startMethod”);

waitHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
this._handler = new ThreadLocal<EventHandler<EventArgs>>(() => new EventHandler<EventArgs>(this.MethodProxyInThread__eventHandler));
this._eventHandler += this._handler.Value;

//TODO : Call start Method Here
//startCall() here
do
{
Console.WriteLine(string.Format(“loopMethod – {0}”, Thread.CurrentThread.ManagedThreadId));
if (this.waitHandle.WaitOne(5000))//rest if no more action, what time-out? to avoid deadlock!
{
//TODO : invoke conditional method; -> parameters
this._functionalHook.Invoke(this.parameter);//, null, null); //=>asynchorous logic
if (!this._isRealProxyStop)
{
this.waitHandle.Reset();
}
}
} while (!this._isRealProxyStop);
//stopCall() here
this._eventHandler -= this._handler.Value;
this.waitHandle.Close();
Console.WriteLine(“Quit the thread”);
}
}

private void MethodProxyInThread__eventHandler(object obj, EventArgs e) //Guys, why this isn’t working, delegation will be running in ThreadPool
{
Console.WriteLine(string.Format(“MethodProxyInThread__eventHandler – {0}”, Thread.CurrentThread.ManagedThreadId));
this._isRealProxyStop = true;
}

//public void PostTerminalEvent()
//{
//    if (MethodProxyInThread._eventHandler != null)
//    {
//        Console.WriteLine(string.Format(“PostTerminalEvent – {0}”, Thread.CurrentThread.ManagedThreadId));
//        MethodProxyInThread._eventHandler(this, new EventArgs());
//    }
//}

public void PostMessage(Func<object, int> _func, object _param)
{
if (!this._isRealProxyStop)
{
this._functionalHook = _func;
this.parameter = _param;

this.waitHandle.Set();
}
}

public void stopMethod()
{
Console.WriteLine(string.Format(“stopMethod – {0}”, Thread.CurrentThread.ManagedThreadId));
this._isRealProxyStop = true;
}
}

class Program
{
static int PostMessageObj(object _obj)
{
Console.WriteLine(string.Format(“postMethod – {0}”, Thread.CurrentThread.ManagedThreadId));
return 5;
}

static void Main(string[] args)
{
MethodProxyInThread proxy = new MethodProxyInThread();
Thread t = new Thread(proxy.startMethod);
t.Start(proxy);

Thread.Sleep(5000);
proxy.PostMessage(new Func<object, int>(Program.PostMessageObj), 6);
Thread.Sleep(5000);
proxy.stopMethod();
//proxy.PostTerminalEvent();
Thread.Sleep(10000);
}
}

 

Of Course, that’s not the ultimate version, For Message Loop, we need dictionary<enum, Func<object, object>> for checking-up, and parameter lists.

Like it, or some more suggestions… Whatever :-). No-UI SynchronizationContext Solution.